RDLC subreport and rdlc report
1. Drag the RDLC design page into the table or rectangle.
2. Right-click a table or a rectangular cell, and insert a subreport.
3. Enter a name and use the report as a subreport.
Name: displayed on the design page for viewing purposes only
Use this report as a subreport: Enter the file name in the directory that needs to be the RDLC file of the subreport (XXX. RDLC), Only the file name does not need the. RDLC suffix name.
4. Right-click the subreport cell and select "subreport properties"> "Parameters" to add the parameter information to be passed to the subreport.
5. Open the report attribute on the subreport design page, right-click the parameter, add the parameter, and enter the parameter name entered in step 1.
6.
Viewer. localReport. subreportProcessing + = new SubreportProcessingEventHandler (LocalReport_SubreportProcessing); // Add void LocalReport_SubreportProcessing (object sender, Microsoft. reporting. webForms. subreportProcessingEventArgs e) {var errCode = 100; try {if (e. dataSourceNames [0] = "dsJcxh") // Replace the data set name in the quotation mark with the subreport {errCode = 3; e. dataSources. add (new ReportDataSource ("dsJcxh", GetSupervisionSamplingDetailData (e); // if there is only one subreport, ELSE is not required, more than three IF statements can be made.} else {errCode = 4; e. dataSources. add (new ReportDataSource ("dsUr", GetUseRegisterData (e) ;}} catch (Exception ex) {Response. write (ex. message + ":" + errCode) ;}} public List <StatisticalLedger> GetSupervisionSamplingDetailData (SubreportProcessingEventArgs e) {// accept the parameter string productDictId = e in the rdlc of the subreport. parameters ["productDictId"]. values [0]; string spec = e. parameters ["spec"]. values [0]; string certificateNo = e. parameters ["certificateNo"]. values [0]; var list = new StatisticalLedgerBL (). partition (productDictId, spec, certificateNo); return list;} public List <StatisticalLedger1> GetUseRegisterData (SubreportProcessingEventArgs e) {// accept the parameter string productDictId = e in the rdlc of the subreport. parameters ["productDictId"]. values [0]; string spec = e. parameters ["spec"]. values [0]; var list = new StatisticalLedgerBL (). getUseRegisterData (productDictId, spec); return list ;}View Code