问题
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)
回答1:
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
来源:https://stackoverflow.com/questions/11672237/using-datatable-as-datasource-in-micrsosoft-report-viewer