简体   繁体   中英

Unable to bind datasource to reportViewer

I have a C# application that uses a reportViewer . I want to add 3 reports in a single reportViewer . Here is the code for a single report:

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();
}

However when I run my application, I get the following error

A data source instance has not been supplied for the data source 'DataSet1'

What can be the possible mistake?

  1. Open rdlc file as text
  2. Replace DataSet1 with First_Year_IT_AttendanceBindingSource

Check that the columns (fields) in rdlc is 'equal' to columns in your data source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM