我试图从代码加载我的 ASP.NET 报告查看器,我收到以下错误 A data source instance has not been supplied for the data source
这是我的代码:
Class_Connection.cnn.Close();
Class_Connection.cnn.Open();
var cmd = new SqlCommand("select * from TT", Class_Connection.cnn);
var dt = new DataTable();
dt.Load(cmd.ExecuteReader());
var source = new ReportDataSource(dt.TableName, dt);
RV_Main.LocalReport.DataSources.Clear();
RV_Main.LocalReport.ReportPath = Server.MapPath("~/Reports/AllTTByLastWeek.rdlc");
RV_Main.LocalReport.DataSources.Add(source);
RV_Main.LocalReport.Refresh();
如何从不在 GUI 控件中的代码提供数据源实例?
最佳答案
我必须在 IDE 中通过 GUI 在属性中设置数据源。如果没有它,它就无法工作,即使我在后面设置了代码。
关于c# - 如何在代码 C# ASP.NET 中为报表查看器提供数据源实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29102329/