2013-03-16 96 views
0

我有一个使用reportViewer的C#应用​​程序。我想在一个reportViewer中添加3个报告。这里是一个报表代码:无法将数据源绑定到reportViewer

ReportDataSource rds = new ReportDataSource(); 
this.reportViewer1.LocalReport.DataSources.Clear(); 
if (comboBoxReports.SelectedIndex == 0) 
{ 
    reportViewer1.Reset(); 
    reportViewer1.LocalReport.ReportPath = "D:\\AMOS\\WindowsFormsApplication1\\WindowsFormsApplication1\\Report2.rdlc"; 
    rds.Name = "First_Year_IT_AttendanceBindingSource"; 
    rds.Value = this.First_Year_IT_AttendanceBindingSource; 
    reportViewer1.LocalReport.DataSources.Add(rds); 
    this.reportViewer1.RefreshReport(); 
} 

然而,当我跑我的申请,我得到以下错误

的数据源实例尚未为数据源“数据集1”

提供

可能的错误是什么?

+0

'平等' 的列也许它http://stackoverflow.com/questions/8802707/setting-the-datasource-for-a-local-report-net-report-viewer帮助你找到答案 – 2013-03-16 19:09:50

+0

rds的名称必须m使用RDLC中的DataSource – 2013-03-16 19:12:21

回答

2
  1. 打开RDLC文件为文本
  2. 更换数据集1First_Year_IT_AttendanceBindingSource

检查在RDLC列(字段)是在您的数据源