Using datatable as datasource in micrsosoft report viewer

五迷三道 提交于 2020-01-06 14:49:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!