您好!后台绑定数据的类型为datable类型,还有就是您的报表设计可能也存在一点问题。这是后台数据绑定的代码,您参考下
- public partial class WebForm1 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath(@"动态数据源.rdlx")));
- rpt.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(locatedate);
- this.WebViewer1.Report = rpt;
- }
- private void locatedate(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
- {
- if (args.DataSourceName == "DataSource1")
- {
- if (args.DataSetName == "DataSet1")
- {
- args.Data = returndata();
- }
- }
- }
- private DataTable returndata()
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("产品编号");
- dt.Columns.Add("产品名称");
- dt.Columns.Add("单价");
- dt.Columns.Add("库存量");
- dt.Rows.Add("A001", "苹果", 10, 300);
- dt.Rows.Add("A002", "葡萄", 20, 200);
- dt.Rows.Add("A003", "香蕉", 30, 400);
- return dt;
- }
复制代码
|