水晶报表子报表

水晶报表子报表

主要分两步:

 一,添加报表文件

1)添加主报表数据集treatmentCharge.xsd: 画红线处表示名字在后面中要用到的地方,因为有些地方需要名字一致


2)添加子报表数据集treatmentChargeSub.xsd


3)添加主报表 治疗费用单.rdlc,同时添加数据集


4)在主报表文件中拖入子报表控件,然后单机子报表控件右键,添加子报表名字,同时添加参数








5)添加子报表治疗费用单子报表.rdlc,同时添加数据集,注意名字要一致


6)给子报表治疗费用单子报表.rdlc添加参数,参数跟我们之前在主报表的子报表控件参数要一致





二,后台绑定数据源

主要代码:
   DataSet ds = commonws.GetDsOnlySql(strSql);
                if(ds.Tables.Count>1)
                    Report_sub = ds.Tables[1];

                //子报表
                ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);     

                this.ReportViewer1.LocalReport.ReportPath = Report_Path;
                this.ReportViewer1.LocalReport.DataSources.Clear();
                this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("bpis_patient_info", ds.Tables[0]));
                ReportParameter rp_title = new ReportParameter("report_title",cc.Hospital_Name + Report_Title);
                ReportParameter rp_date = new ReportParameter("report_date", Report_Date);
                this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp_title,rp_date });
                this.ReportViewer1.LocalReport.Refresh();

   /// <summary>
    /// 子报表
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
    {
        e.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DTSub", Report_sub));
    }

效果:


      

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值