【发布时间】:2013-03-31 10:32:09
【问题描述】:
朋友们,我用c#开发了一个简单的应用程序,它有两个rdlc报告
我使用下面的代码将数据源绑定到报告查看器
this.reportViewer1.LocalReport.ReportPath = @"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\reports\reports\Report1.rdlc";
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("customer", dt.Tables[0])) ;
this.reportViewer1.RefreshReport();
但是当生成报告时,它是空报告,不会显示任何数据,有什么意见???
【问题讨论】:
-
dt.Tables[0]真的包含数据吗?另外:您报告中的数据源是否称为customer? -
@marc_s - 是的,我用 forloop 测试了数据在客户表的数据集中,reportDataSource 名称应该是什么?表名还是数据集名? `reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("customer", dt.Tables[0])) ;`
-
数据源的名称在您的报告中需要与您在调用
new ReportDataSource(....)时使用的名称相同 - 如果您在调用它时调用它customer创建ReportDataSource,.RDLC报表中的数据源名称也必须是Customer -
@marc_s - 抱歉问这个问题,如何将
datasource分配给.RDLC报告?