- Home
- Forum
- ASP.NET MVC
- Subreports
Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.
We thank you for choosing Syncfusion� and appreciate your understanding.
Subreports
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.
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.
So based on your response:
Thanks for the update.
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() }); } } |
In above example, the ReportLoaded method will be invoke while loading each main and sub reports. So you can pass your data source values to sub report through SubReportModel property.
Sundaraj M.
- 3 Replies
- 3 Participants
-
VS Vance Sankar
- Sep 30, 2015 08:59 PM UTC
- Oct 2, 2015 01:38 PM UTC