Public void OnReportLoaded(ReportViewerOptions reportOption) { if (reportOption.SubReportModel != null) { DataSourceValus val = new DataSourceValus(); reportOption.SubReportModel.DataSources.Add(new ReportDataSource() { Name = "DataSet1", Value = val.GetDataSource() }); } else { DataSourceValus val = new DataSourceValus(); reportOption.ReportModel.DataSources.Add(new ReportDataSource() { Name = "DataSet1", Value = val.GetDataSource1() }); } } |
Hi Hemraj,
Thanks for contacting Syncfusion support.
We have already exposed the SubReportModel property in WebAPI(IReportController) side. By using this, you can pass the DataSource values to Sub Report on Report Loaded method as shown in the below example,
Public void OnReportLoaded(ReportViewerOptions reportOption)
{
if (reportOption.SubReportModel != null)
{
DataSourceValus val = new DataSourceValus();
reportOption.SubReportModel.DataSources.Add(new ReportDataSource()
{
Name = "DataSet1",
Value = val.GetDataSource()
});
}
else
{
DataSourceValus val = new DataSourceValus();
reportOption.ReportModel.DataSources.Add(new ReportDataSource()
{
Name = "DataSet1",
Value = val.GetDataSource1()
});
}
}
We have prepared a sample and it can be downloaded from the below location,
http://www.syncfusion.com/downloads/support/forum/120653/ze/SubReportDemo15842735.zip
Regards,
Soundara Rajan S.
PublicvoidOnReportLoaded(ReportViewerOptionsreportOption) { if(reportOption.ReportModel.ReportPath.Contains("ParentReportName")) { // To load mainreport datasource // DataSourceValusval =newDataSourceValus(); reportOption.ReportModel.DataSources.Add(newReportDataSource() { Name ="DataSet1", Value = val.GetDataSource1() }); } else if(reportOption.SubReportModel !=null) { // To set subreport datasource // DataSourceValusval =newDataSourceValus(); reportOption.SubReportModel.DataSources.Add(newReportDataSource() { Name ="DataSet2", Value = val.GetDataSource() }); } } |