guangfu.kong 发表于 2016-10-17 17:13:59

运行时数据源不生效


      void Document_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
      {
            if (args.DataSourceName == "DataSource1")
            {
                if (args.DataSetName =="DataSet1" )
                {
                  string sqlCommetText = "select LotteryNumber, sum(money) AS MONEYfrom LotteryChase where CreateOn between '{0}' and '{1}'group by LotteryNumber ";
                  sqlCommetText = string.Format(sqlCommetText, txt_S_BuyDateTime.Text, txt_E_BuyDateTime.Text);
                  DotNet.Data.IDbHelper ucDbHelper = DotNet.Data.DbHelperFactory.GetHelper(BaseSystemInfo.BusinessDbType, BaseSystemInfo.BusinessDbConnection);
                  DataTable dt = ucDbHelper.Fill(sqlCommetText);
                  args.Data = dt;
                }
            }
      }

      private void load()
      {
            GrapeCity.ActiveReports.PageReport prt = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("Modules\\ActiveReportTemp\\LotteryChaseReport.rdlx")));
            prt.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
            //prt.Report.ReportParameters.DefaultValue.Values.Clear();
            //prt.Report.ReportParameters.DefaultValue.Values.Add("1");            
            this.WebViewer1.Report = prt;
            this.WebViewer1.DataBind();
      }

执行 load()时,Document_LocateDataSource没有被执行,是什么原因呢?

Lenka.Guo 发表于 2016-10-17 17:26:59

从代码来看没有问题,可以先检查下报表路径是否正确,有没有正常生成报表对象?
如果仍有问题,您可以把您的程序发过来,我在这边测试下。
页: [1]
查看完整版本: 运行时数据源不生效