rusted brain
rusted brain

Reputation: 1062

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?

Upvotes: 0

Views: 2917

Answers (1)

Boris Gappov
Boris Gappov

Reputation: 2493

  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

Upvotes: 2

Related Questions