博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

RDLC-子报表

Posted on 2011-01-28 10:50  Adam哥  阅读(2079)  评论(0编辑  收藏  举报

添加子报表流程:

1.建立一主报表,在其中加入List

2.设置List的Group关系

3.在主报表中加入一子报表控件占位

4.为刚添加的子报表加入参数

5.新建一rdlc报表,用其作为子报表

6.点击报表菜单,为此报表添加参数,参数名与第四步添加的一样

7.为此报表拉入数据,并建立筛选公式,用过过虑数据

8.在主报表的子报表控件中指定报表源为第5步建立的报表

9.在调用主报表的aspx后台代码设置ReportViewer事件,如下:

 ReportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(LocalReport_SubreportProcessing); 
    
    private void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e)
    {
         e.DataSources.Add(new ReportDataSource("ReportDataSet_Client", ds.Tables[0]));
         e.DataSources.Add(new ReportDataSource("ReportDataSet_Product", ds.Tables[1]));
         e.DataSources.Add(new ReportDataSource("ReportDataSet_OrderView", ds.Tables[2]));
    }  

counter