C# – Using datatable as datasource in micrsosoft report viewer

asp.net, c++, datatable, reportviewer

Is it possible to use datatables as datasource for reportviewer component? Can you provide refference or simple steps how to do that?

And one important thing: i'm using reportviewer for webforms (ASP.net)

Best Solution

Try something like this.

this.reportViewer.LocalReport.DataSources.Clear(); DataTable dt = new DataTable(); dt = this.inputValuesTableAdapter.GetData();     Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource(dt.TableName, dt); this.reportViewer.LocalReport.DataSources.Add(rprtDTSource); this.reportViewer.RefreshReport(); 

Hope it helps