前台代码:
- <form id="form1" runat="server">
- <div>
-
- <ActiveReportsWeb:WebViewer ID="WebViewer1" runat="server" height="423px" width="697px">
- </ActiveReportsWeb:WebViewer>
- </div>
- </form>
复制代码 后台代码:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- return;
- }
- GrapeCity.ActiveReports.PageReport report1 = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("PageReport1.rdlx")));
- WebViewer1.LocateDataSource += WebViewer1_LocateDataSource;
- WebViewer1.Report = report1;
- }
- /// <summary>
- /// 该报表存在错误,不能被正常处理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="args"></param>
- void WebViewer1_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
- {
- if (args.DataSourceName == "DataSource2")
- {
- if (args.DataSetName == "DataSet2")
- {
- args.Data = GetData2();
- }
- }
- if (args.DataSourceName == "DataSource1")
- {
- if (args.DataSetName == "DataSet1")
- {
- args.Data = GetData();
- }
- }
- }
- private DataTable GetData()
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("Col1");
- dt.Columns.Add("Col2");
- dt.Columns.Add("Col3");
- dt.Rows.Add(1, 1, 1);
- dt.Rows.Add(2, 1, 1);
- dt.Rows.Add(3, 1, 1);
- dt.Rows.Add(4, 1, 1);
- dt.Rows.Add(5, 1, 1);
- dt.Rows.Add(6, 1, 1);
- return dt;
- }
- private DataTable GetData2()
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("Col1");
- dt.Columns.Add("Col2");
- dt.Rows.Add(21, 1);
- dt.Rows.Add(22, 1);
- dt.Rows.Add(23, 1);
- dt.Rows.Add(24, 1);
- dt.Rows.Add(25, 1);
- dt.Rows.Add(26, 1);
- return dt;
- }
复制代码
配置为WEB站点后,发布。如下图所示:
如果勾选此项,发布后正常
如果不勾选此项,则发布后,浏览打印的内容是报错,请问要如何不勾选此项能发布成功?
谢谢。 |