I created 4 reports that contain information from 4 tables in a database. In my application I have a menuStrip that contains items that are named as this reports. How can I make my applications reportViewer display the report selected in the menuStrip?
I tried this code:
ReportDataSource RDS = new ReportDataSource();
RDS.Value = this.KontrolorKazneBindingSource;
reportViewer1.LocalReport.DataSources.Add(RDS);
reportViewer1.LocalReport.ReportPath = @"C:\Users\User\documents\visual studio 2010\Projects\Kontrolor\Kontrolor\KontrolorKazne.rdlc";
reportViewer1.RefreshReport();
But I get an error: A data source instance has not been suplied for the data source
Can you tell me what I’m doing wrong and how can I solve this problem?
First of all I think you should call
reportViewer1.Reset()to tell ReportViewer to create a new LocalReport instance for you. (MSDN)After that you may give your ReportDataSource a name:
YourReportDataSourceNameis the one you have set in report designer in the Report Data pane.