C# 获取错误“;子报表&x27;的数据检索失败;子报告1'”; 我正在努力使子报表正常工作。我正在使用VS 2017。在将我的子报表添加到主报表时,我收到一条错误消息,如“子报表的数据检索失败,'Subreport1',位于…”。这是我的密码: public override int RunReport(ref ReportViewer rvNextgenReport) { DateTime dt=Convert.ToDateTime(ReportCriteria.DeliveryDate,CultureInfo.InvariantCulture); 字符串FormattedDeliveryDate=BasePage.GetUSFormattedDate(dt,此.REPORT\u BS\u DATE\u格式); 字符串FormattedShortDeliveryDate=BasePage.GetUSFormattedDate(dt,this.REPORT\u SHORT\u DATE\u格式); string GenerationTime=BasePage.GetUSFormattedDate(DateTime.Now,this.REPORT\u GEN\u DATE\u格式); 字符串firstRouteId; int find=ReportCriteria.RouteId.ToString().IndexOf(','); 如果(find>0)firstRouteId=ReportCriteria.RouteId.ToString().Substring(0,find); 其他的 firstRouteId=ReportCriteria.RouteId; //设置报告的参数 reportParam=新的ReportParameter[]{ 新的ReportParameter(“Branch”,ReportCriteria.BranchName), 新的ReportParameter(“DeliveryDate”,ReportCriteria.DeliveryDate), 新的ReportParameter(“IncludeRouteNotesAfterDI”,ReportCriteria.IncludeRouteNotesAfterDI?”1):“0”), 新报告参数(“FormattedDeliveryDate”,FormattedDeliveryDate), 新报告参数(“FormattedShortDeliveryDate”,FormattedShortDeliveryDate), }; rvNextgenReport.LocalReport.ReportPath=“routecardenewsub.rdlc”; rvNextgenReport.LocalReport.SubreportProcessing+=新的SubreportProcessingEventHandler(LocalReport\u SubreportProcessing); 返回运行报告(参考rvNextgenReport); } public void LocalReport_SubreportProcessing(对象发送方,SubreportProcessingEventArgs e) { LocalReport lr=(LocalReport)发送方; e、 DataSources.Clear(); 报告数据源rds; 如果(例如,ReportPath.Contains(“sureportsNewSub”)) { 字符串routeId=e.Parameters[“routeId”]。值[0]; for(int index=1;index

C# 获取错误“;子报表&x27;的数据检索失败;子报告1'”; 我正在努力使子报表正常工作。我正在使用VS 2017。在将我的子报表添加到主报表时,我收到一条错误消息,如“子报表的数据检索失败,'Subreport1',位于…”。这是我的密码: public override int RunReport(ref ReportViewer rvNextgenReport) { DateTime dt=Convert.ToDateTime(ReportCriteria.DeliveryDate,CultureInfo.InvariantCulture); 字符串FormattedDeliveryDate=BasePage.GetUSFormattedDate(dt,此.REPORT\u BS\u DATE\u格式); 字符串FormattedShortDeliveryDate=BasePage.GetUSFormattedDate(dt,this.REPORT\u SHORT\u DATE\u格式); string GenerationTime=BasePage.GetUSFormattedDate(DateTime.Now,this.REPORT\u GEN\u DATE\u格式); 字符串firstRouteId; int find=ReportCriteria.RouteId.ToString().IndexOf(','); 如果(find>0)firstRouteId=ReportCriteria.RouteId.ToString().Substring(0,find); 其他的 firstRouteId=ReportCriteria.RouteId; //设置报告的参数 reportParam=新的ReportParameter[]{ 新的ReportParameter(“Branch”,ReportCriteria.BranchName), 新的ReportParameter(“DeliveryDate”,ReportCriteria.DeliveryDate), 新的ReportParameter(“IncludeRouteNotesAfterDI”,ReportCriteria.IncludeRouteNotesAfterDI?”1):“0”), 新报告参数(“FormattedDeliveryDate”,FormattedDeliveryDate), 新报告参数(“FormattedShortDeliveryDate”,FormattedShortDeliveryDate), }; rvNextgenReport.LocalReport.ReportPath=“routecardenewsub.rdlc”; rvNextgenReport.LocalReport.SubreportProcessing+=新的SubreportProcessingEventHandler(LocalReport\u SubreportProcessing); 返回运行报告(参考rvNextgenReport); } public void LocalReport_SubreportProcessing(对象发送方,SubreportProcessingEventArgs e) { LocalReport lr=(LocalReport)发送方; e、 DataSources.Clear(); 报告数据源rds; 如果(例如,ReportPath.Contains(“sureportsNewSub”)) { 字符串routeId=e.Parameters[“routeId”]。值[0]; for(int index=1;index,c#,asp.net,ssrs-2008,rdlc,aspx-user-control,C#,Asp.net,Ssrs 2008,Rdlc,Aspx User Control,请注意,我不会在e中获取报告路径。LocalReport\u SubreportProcessing中的Reportspath,我认为这可能会导致这个问题。因此,请有人解释为什么这个对象没有获得reportspath信息 public override int RunReport(ref ReportViewer rvNextgenReport) { DateTime dt = Convert.ToDateTime(ReportCriteria.DeliveryDate,

请注意,我不会在e中获取报告路径。LocalReport\u SubreportProcessing中的Reportspath,我认为这可能会导致这个问题。因此,请有人解释为什么这个对象没有获得reportspath信息

public override int RunReport(ref ReportViewer rvNextgenReport)
    {
        DateTime dt = Convert.ToDateTime(ReportCriteria.DeliveryDate, CultureInfo.InvariantCulture);
        string FormattedDeliveryDate = BasePage.GetUSFormattedDate(dt, this.REPORT_BS_DATE_FORMAT);
        string FormattedShortDeliveryDate = BasePage.GetUSFormattedDate(dt, this.REPORT_SHORT_DATE_FORMAT);
        string GenerationTime = BasePage.GetUSFormattedDate(DateTime.Now, this.REPORT_GEN_DATE_FORMAT);
        string firstRouteId;

        int find = ReportCriteria.RouteId.ToString().IndexOf(',');

        if (find > 0) firstRouteId = ReportCriteria.RouteId.ToString().Substring(0, find);
        else
            firstRouteId = ReportCriteria.RouteId;


        // set the report's parameters
        reportParam = new ReportParameter[] {
                            new ReportParameter("Branch", ReportCriteria.BranchName),
                            new ReportParameter("DeliveryDate", ReportCriteria.DeliveryDate),
                            new ReportParameter("IncludeRouteNotesAfterDI", ReportCriteria.includeRouteNotesAfterDI?"1":"0"),
                            new ReportParameter("FormattedDeliveryDate", FormattedDeliveryDate),
                            new ReportParameter("FormattedShortDeliveryDate", FormattedShortDeliveryDate),

                     };


        rvNextgenReport.LocalReport.ReportPath = "RouteCardNewSub.rdlc";

        rvNextgenReport.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
        return runReport(ref rvNextgenReport);
    }

    public void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
    {
        LocalReport lr = (LocalReport)sender;
        e.DataSources.Clear();
        ReportDataSource rds;

        if (e.ReportPath.Contains("sureportsNewSub"))
        {
            string routeId = e.Parameters["RouteId"].Values[0];

            for (int index = 1; index < lr.DataSources.Count; index++)
            {
                DataTable dt = (DataTable)lr.DataSources[index].Value;
                DataView dv = new DataView(dt);
                dv.RowFilter = string.Format("RouteId={0}", routeId);
                rds = new ReportDataSource(string.Format("RouteCardNew_DataTable{0}", index + 1), dv.ToTable());
                e.DataSources.Add(rds);
            }
        }
    }