问题描述:利用RDL报表实现后台绑定数据集,一个数据集按照官方教程绑定运行时数据源可以时间,但报表绑定多个DataSet,则提示”报表存在问题“
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
return;
}
GrapeCity.ActiveReports.PageReport report1 = new GrapeCity.ActiveReports.PageReport();
report1.Load(new System.IO.FileInfo(Server.MapPath("../") + "\\Report\\PageReport_DataSource_DesignTime.rdlx"));
report1.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
report1.Report.ReportParameters[0].DefaultValue.Values.Clear();
report1.Report.ReportParameters[0].DefaultValue.Values.Add("1");
WebViewer1.Report = report1;
}
void Document_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
{
if (args.DataSourceName == "DataSource1")
{
if (args.DataSetName == "DataSet1")
{
args.Data = GetDataSource();
}
}
}
private DataTable GetDataSource()
{
DataTable dt = new DataTable();
dt.Columns.Add("产品编号");
dt.Columns.Add("产品名称");
dt.Columns.Add("单价");
dt.Columns.Add("库存量");
dt.Rows.Add("A10002", "苹果", 20, 50);
dt.Rows.Add("A15681", "香蕉", 20, 50);
dt.Rows.Add("A15681", "菠萝", 20, 50);
return dt;
} |