How to set DataSource for RDLC Report using Report Viewer in C#

In this tutorial, I'll show you how to set DataSource for local report using report viewer in C#.NET Windows Forms Application

To play the demo, You should create a new dataset, then add a new table to your dataset.

Next, you need to create a new local report, then add a data source to your report

To set data source for the local report at run time you can write your code as shown below

ReportData data = ReportData();//ReportData is a dataset
//If your report needs parameters, they need to be set
ReportParameter[] parameters = new ReportParameter[...];
ReportDataSource reportDataSource = new ReportDataSource();
//Must match the DataSource in the RDLC
reportDataSource.Name = "ReportData"; 
reportDataSource.Value = data.Customer; //Your table in ReportData
// Add any parameters to the collection
reportViewer1.LocalReport.SetParameters(parameters); 
reportViewer1.LocalReport.DataSources.Add(reportDataSource);
reportViewer1.RefreshReport();

You need to create a ReportDataSource, then set data to the Value property - e.g. DataTable and IEnumerables are supported sources