You can use subreports and drill-down reports to link relevant reports.
A subreport is an item that is embedded into another report in the table of the parent report. In terms of concept, subreports are similar to the frameworks in web pages that provide containers for other web pages. The subreport is displayed in the parent report that contains the subreport. Both reports are processed and displayed.
A drilling report is a report created when you want to support drilling links to other related reports. Generally, a drilling report is associated with a parent report through data. An example of a common drilling report is a monthly sales report that contains links to each sales order in the current month. When you click the drilling link, the parent report is replaced by other reports that support detailed information.
Both Drilling Reports and subreports support the concept of parent and subreports. To associate these reports, you must create report parameters to pass the data used to establish the relationship. To link these reports at runtime, you must write code that supports this connection. When deploying related reports, make sure that the client report definition (. rdlc) files are stored in the same folder on the file system.
The following event provides sample code to illustrate how to implement subreports and drilling operations:
Drillthrough
Subreportprocessing
Drillthrough
Subreportprocessing
Add subreport
Subreports and their parent reports should be associated with the shared parameters. Parameters must be added for each report. You must configure these parameters before adding a subreport to the parent report. When adding a subreport, you must set the parent report to pass parameters to the subreport.
Add subreport
In graphic design mode, open the client report definition (. rdlc) file.
In the toolbox, click subreport ".
On the Design surface, drag a box to adjust the size of the subreport as needed. Alternatively, you can click the design surface to create a fixed-size subreport.
Note: |
If a sub-report already exists in the project, you can drag the report from Solution Explorer to the design drawing to create a sub-report. |
Right-click the subreport and then click "properties ".
In "subreport", select the report that you want to display in the subreport area.
On the parameters tab, perform the following operations:
In "parameter name", type the parameter name in the subreport. This name must match the name of the report parameter named in the reportname attribute.
In "parameter value", type the value to be passed to the subreport. This value can be static text or an expression pointing to a field or other object in the parent report.
Repeat Step 2 to add other parameters to be passed to the subreport.
Note: |
All parameters required by the subreport must be included in the "Parameters" list. If necessary parameters are missing, the subreport is not correctly displayed in the parent report. |
To provide data for a subreport, the application must process the subreportprocessing event of the localreport object. Subreportprocessingeventargs is one of the parameters passed to the subreportprocessing event handler method. In the event handler, the application checks the parameter values passed to the subreport using the parameters attribute of subreportprocessingeventargs. Then, the application must use the CES attribute of subreportprocessingeventargs to provide data for the subreport.
Configure Drilling Reports
You can configure a drill-down report by defining the drill-down operation that allows you to navigate from the parent report to a sub-report containing supported data.
A drilling report usually contains parameters passed to it by the parent report. Taking the sales summary report as an example, the drilling report contains a parameter with the order value. The summary report contains links to the drill-down report corresponding to each order number. Click this link to open the target report containing detailed information and pass the corresponding order ID to it.
Any report stored on the Report Server can be a drill-down report. You can only add drilling links to text boxes and images.
Add drilling Report link
In graphic design mode, open the client report definition (. rdlc) file.
Right-click the text box or image to which you want to add a link, and then click Properties ".
On the "navigation" tab, select "Jump to report ".
Type or select a report name. The report must be a. rdlc file in the same project.
To set parameters that are passed to the drilling report, click "Parameters" and then perform the following operations:
In "parameter name", type the name of the report parameter in the drilling report.
Note: |
The name in the parameter list must exactly match the expected parameter name in the target report. If the name does not match or an expected parameter is not listed, the drilling report will fail. |
In "parameter value", type or select the parameter value that you want to pass to the drilling report.
Note: |
A value can contain an expression that calculates the value passed to the report parameter. The expression in the Value List includes the field list of the current report. |
To provide data for a drilling Report, the application must process the drillthrough event of the reportviewer object. Drillthrougheventargs is one of the parameters passed to the drillthrough event handler method. Drillthrougheventargs has a report attribute used to represent a drill-down report. In the event processing program, the host application can call the getparameters () method on the drill-down report to check the parameter values passed to the drill-down report. Then, the host application must use the CES attribute of the drilling report to provide data for the drilling report.
For more information, see concepts.
Define report parameters in a reportviewer report
Add interaction, visibility, and navigation to reportviewer reports
Other resources
Examples and drills