Articles in this section
Category / Section

How to load SubReport in Syncfusion ASP.NET Web forms Report Viewer

2 mins read

Syncfusion ASP.NET ReportViewer allows you to render reports, which are embedded with one another using the subreport report item. The following steps help you to load the RDLC report with subreport item in a ReportViewer:

1. Create a simple ReportViewer application with the help of getting started documentation.

2. Right-click the project and go to the Add New Item dialog. In the dialog, select Report Wizard and name it as MainReport.rdlc for the report, and then click Add.

3. Repeat the step_2 to add the subreport and name it SubReport.rdlc.

4. Right-click the subreport, and then click Subreport Properties.

5. As per the RDL standards, you can set the SubReport Path and properties like Microsoft ReportViewer as follows. In the Subreport Properties dialog box, type a name in the Name text box. The name must be unique within the report.

Provide unique subreport name

6. You can pass the data source values to the OnReportLoaded method of subreport as shown in the following example.

public void OnReportLoaded(ReportViewerOptions reportOption)
{
    if (reportOption.SubReportModel != null)
    {
reportOption.SubReportModel.DataSources.Add(new ReportDataSource { Name = "StoreSales", Value = StoreSales.GetData() });
    }
    else
    {
      reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "TopSalesPerson", Value = SalesPersons.GetTopSalesPerson() });
    }
}

List of supported properties of subreport

The ReportViewer has the following subreport properties to set the DataSources, Parameters, and more through code behind.

DataSources

Gets/sets the data source of the subreport.

DataSourceName

Gets the data source names of the subreport.

Parameters

Gets/sets the parameters to the subreport.

ReportPath

Gets/sets the report path of the subreport.

Stream

Sets the report stream to subreport.

 

Run the application

Run the sample application. You can see the RDLC subreport loaded in the ReportViewer as shown in the following screenshot.

       RDLC subreport loaded in ReportViewer

Download the load subreport sample from here.

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied