我试图在运行时将DataTable绑定到winforms中的reportviewer,但在reportviewer中收到此消息(而不是异常)。“
尚未指定报表定义的来源“
下面是我的代码:
this.rptViewer.LocalReport.DataSources.Clear(); 
ReportDataSource rprtDTSource = new ReportDataSource(dt.TableName, dt); 
this.rptViewer.LocalReport.DataSources.Add(rprtDTSource); 
this.rptViewer.RefreshReport(); 有什么想法吗?
发布于 2013-06-29 03:41:40
试着这样做:
var reportDataSource1 = new ReportDataSource { Name = "WpfApplication17_User", Value = _users };
string exeFolder = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
_reportViewer.LocalReport.ReportPath =exeFolder + @"\Reports\Report1.rdlc";
_reportViewer.LocalReport.DataSources.Add(reportDataSource1);
_reportViewer.RefreshReport();从here (Codeproject)那里得到了答案。
https://stackoverflow.com/questions/17372407
复制相似问题