当前位置:编程学习 > C#/ASP.NET >>

winfrom中RDLC报表怎么动态绑定DataTable为数据源?

在网上找到一个教程,我的步骤是这样的:
1.自己建立一个dataset1.xsd文件,在里面新建一个datatable,各列名称和后面动态生成的DataTable列名一样,然后在设计RDLC报表的时候,直接把要显示的列拖进去。
2.在reportViewer1中选择刚刚新建好的报表,数据源为dataset1中的datatable。
3.然后后台获取DataTable重新绑定代码为:
ReportDataSource rds = new ReportDataSource("DSPrint_DTBusiness", DataTable);
            reportViewer1.LocalReport.DataSources.Clear();
            reportViewer1.LocalReport.DataSources.Add(rds);
            reportViewer1.LocalReport.Refresh();


程序运行后什么都没有显示,请问应该怎么动态绑定才对呢? --------------------编程问答-------------------- 我也想知道哦 --------------------编程问答-------------------- 把你报表里的表属性改下,选择数据集里的表,这样的话你就直接用下面代码就行了
ReportDocument report = new ReportDocument();
report.Load(这里是你的报表的路径);
DataSet ds = new DataSet();
ds.Tables.Add(你的数据表);
ds.Tables[0].TableName = "DSPrint_DTBusiness"; //这里是你数据集中表的名字
report.SetDataSource(ds);
crystalReportViewer1.ReportSource = report;
这样就一定会显示。 rdlc格式的不太会用,我用的crystalReportView,楼主自己变通下
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,