ehm*_*mad 4 c# reporting reportviewer
我想做的事情如下:
this.reportViewer.LocalReport.DataSources.Clear();
DataTable dt = new DataTable();
dt = this.inputValuesTableAdapter.GetData();
Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource();
rprtDTSource = dt; // this line generates exception
//this.reportViewer.LocalReport.DataSources.Add(rprtDTSource);
this.reportViewer.RefreshReport();
Run Code Online (Sandbox Code Playgroud)
如何将数据表加载为ReportDataSource?
当前代码生成: "无法将类型'System.Data.DataTable'隐式转换为'Microsoft.Reporting.WinForms.ReportDataSource'"
mad*_*onw 10
您没有正确初始化ReportDataSouce.尝试一下:
this.reportViewer.LocalReport.DataSources.Clear();
DataTable dt = new DataTable();
dt = this.inputValuesTableAdapter.GetData();
Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource(dt.TableName, dt);
this.reportViewer.LocalReport.DataSources.Add(rprtDTSource);
this.reportViewer.RefreshReport();
Run Code Online (Sandbox Code Playgroud)
此外,您可能需要将第一个参数更改为ReportDataSource构造函数,以设置报表所期望的数据源的名称.
| 归档时间: |
|
| 查看次数: |
47054 次 |
| 最近记录: |