RDLC 子報表


1.RDLC 設計頁面,拖入table或者矩形

2.右擊表格或者矩形單元格,插入--子報表

3.輸入名稱和將此報表用作子報表

   名稱:顯示在設計頁面上的,僅作觀看作用

  將此報表用作子報表:填寫目錄下的需要作為子報表的RDLC文件的文件名稱(XXX.RDLC),只需要文件名稱不需要.RDLC后綴名稱。

4.右擊子報表單元格,子報表屬性--參數,添加需要傳給子報表的參數信息

5.打開子報表設計頁面的報表屬性,右擊參數,添加參數,輸入第4步填寫的參數名稱

6.

 viewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
//主函數添加
 void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e)
        {
            var errCode = 100;
            try
            {
                if (e.DataSourceNames[0] == "dsJcxh")
                          //這里引號里替換成子報表的數據集名稱
                {
                    errCode = 3;
                    e.DataSources.Add(new ReportDataSource("dsJcxh", GetSupervisionSamplingDetailData(e)));
//如果只有1個子報表ELSE后面就不需要了,3個以上 多次IF判斷就可以了
                }
                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) {
           //接受子報表RDLC里面的參數
            string productDictId =e.Parameters["productDictId"].Values[0];
            string spec = e.Parameters["spec"].Values[0];
            string certificateNo = e.Parameters["certificateNo"].Values[0];    
                   var list = new StatisticalLedgerBL().GetSupervisionSamplingDetailData(productDictId, spec, certificateNo);
            return list;
        }
        public List<StatisticalLedger1> GetUseRegisterData(SubreportProcessingEventArgs e)
        {
           //接受子報表RDLC里面的參數
            string productDictId = e.Parameters["productDictId"].Values[0];
            string spec = e.Parameters["spec"].Values[0];
            var list = new StatisticalLedgerBL().GetUseRegisterData(productDictId, spec);
            return list;
        }
       
View Code

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM