【发布时间】:2016-01-29 05:40:13
【问题描述】:
我有一个报告查看器。我想动态生成一个数据表并将其设置为我的报告查看器的数据源。报表查看器不显示数据。我的代码如下:
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = "report1.rdlc";
ReportDataSource rdS = new ReportDataSource("report", dt);
ReportViewer1.LocalReport.DataSources.Add(rdS);
有什么建议吗?
【问题讨论】:
-
这里可能发生了太多事情。报告中是否有参数。数据表是否与用于设计报告的数据集兼容?
-
没有参数。这是一个简单的报告,我想将数据源设置为数据表。另外,我没有使用任何数据集。我只是获取数据表并显示它
-
好吧,您不能只传入数据源而不将其定义为报表中的数据集。此外,请确保数据源的名称
report与报告中的数据集名称匹配。 -
我试过这个:ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = "report1.rdlc";数据集 1 ds = 新数据集 1(); ds.Tables.Add(dt); ReportDataSource rdS = new ReportDataSource(ds.Tables [0].TableName, ds.Tables[0]); ReportViewer1.LocalReport.DataSources.Add(rdS); ReportViewer1.LocalReport.Refresh();它仍然无法正常工作。在这里,Dataset1 是我添加到我的网站的数据集
标签: c# asp.net reportviewer