Report drilling Report (4)

Source: Internet
Author: User

1. Use the previous report data source to create a primary report and a subreport (subreport)

2. Set drilling parameters in the subreport table, that is, Department.

3. Set the main report drilling link.

In the "operations" column of the text box. Enable the "go to report" button for the hyperlink and select a subreport.

Then, add a parameter, that is, select the drilling parameter of the subreport and select the passed field in the value.

4. Modify the subreport data source (this step can be omitted if it is only ported to a web project. SSRS cannot be ignored)

In this case, the drill-down report can be previewed. But in order to port it to a web project, continue...

5. In web projects, drilling reports must implement Drillthrough events.

View Code

/// <Summary> /// subreport data source /// </summary> /// <param name = "para"> Drilling Parameter </param> /// <returns> data source table </returns> private DataTable GetChildData (string para) {DataTable dt = new DataTable (); string text = "select * from HumanResources. vEmployeeDepartment where Department = '"+ para +"' "; dt = SqlHelper. executeDataset (BaseCommon. connectionString, CommandType. text, text ). tables [0]; return dt;} protected vo Id rptvContainer_Drillthrough (object sender, DrillthroughEventArgs e) {LocalReport Report = (LocalReport) e. report; Report. reportPath = Report. reportPath. remove (Report. reportPath. length-1); // Report. dataSources. add (new ReportDataSource ("DataSet1", // GetChildData (Report. originalParametersToDrillthrough [0]. values [0]); ReportParameterInfoCollection co = Report. getParameters (); if (co. count> 0) {For (int I = 0; I <co. Count; I ++) {if (! String. isNullOrEmpty (co [I]. values [0]) {Report. dataSources. add (new ReportDataSource ("DataSet1", GetChildData (co [I]. values [0]) ;}} Report. refresh ();}

NOTE: If drilling parameters are only applicable, you can use the OriginalParametersToDrillthrough indexer. The GetParameters method is recommended in msdn. This method gets a set of all parameters of the report.

Because the report object obtained by web project is rdlc by default, but the report is rdl, the last bit can be taken to match the actual path.

The main and subreports are as follows.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.