代码之家  ›  专栏  ›  技术社区  ›  imBlue

SSRS-子报表中的子报表

  •  0
  • imBlue  · 技术社区  · 6 年前

    我正在建立一个用户可以导出的报告,我遇到了一些困难。我希望有人能给我一些建议,因为我开始有点灰暗了。


    问题

    我有 CalcTable 存储的父行 CalcTableMonthly . 从中检索行 可计算的 我使用标识符 LeaseID . 因为有多行 可计算的 一岁以下 每一排 可计算的 每月计算 .

    MainReport 从中获取值 通过 .

    这个 SubReport1 每月计算 利塞德 . 这些值是所有可用值的组合 可计算的 中有值的行 .

    最后呢 SubReport2 获取该月的所有组合值。所以我必须通过考试 利塞德 Month 来自子报表1。

    enter image description here

    页面加载

     protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                // Get LeaseID from query string
                sqls_Summary.SelectParameters["LeaseID"].DefaultValue = Request["LeaseID"];
                // Set report path
                this.rep_Main.LocalReport.ReportPath = "Reports\\CalculationReports\\rpt_Summary_Export.rdlc";
                // Set Report DataSources
                this.rep_Main.LocalReport.DataSources.Add(new ReportDataSource("dsLeaseCalculations", sqls_Summary));
                this.rep_Main.LocalReport.DataSources.Add(new ReportDataSource("dsLeaseCalculationsMonths", sqls_Summary_Months));
                this.rep_Main.LocalReport.DataSources.Add(new ReportDataSource("dsLeaseCalculationsViewMonth", sqls_Summary_ViewMonth));
                // Set the subreport processing event.
                this.rep_Main.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(subReportProccessingFunc);
                this.rep_Main.LocalReport.Refresh();
            }
    
        }
    

    子报表处理事件

    public void subReportProccessingFunc(object sender, SubreportProcessingEventArgs e)
        {
            sqls_Summary_Months.SelectParameters["LeaseID"].DefaultValue = e.Parameters["prmLeaseID"].Values.First();
            e.DataSources.Add(new ReportDataSource("dsLeaseCalculationsMonths", sqls_Summary_Months));
    
            sqls_Summary_ViewMonth.SelectParameters["LeaseID"].DefaultValue = e.Parameters["prmLeaseID"].Values.First();
            sqls_Summary_ViewMonth.SelectParameters["Month"].DefaultValue = // What to put here????
            e.DataSources.Add(new ReportDataSource("dsLeaseCalculationsViewMonth", sqls_Summary_ViewMonth));
        }
    

    从上面的代码行 sqls_Summary_ViewMonth.SelectParameters["Month"].DefaultValue =

    1. 在谷歌上搜索类似的问题,什么也找不到
    2. 将DefaultValue设置为 e.Parameters["LiabilityDate"].Values.First()

    那是因为我真的不知道。。。


    我有一个主报表,主报表有一个子报表,子报表有另一个子报表。为了检索子报表,我只将LeaseID值传递给它。第一个子报表也只需要LeaseID 但是 与第一个子报表位于一起的第二个子报表需要LeaseID 以及 在报表生成器的rdl中工作,如下图所示 但遗憾的是,当我在ASP.net中使用它时,它不起作用

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  0
  •   imBlue    6 年前

    经过一番修修补补,我离开了我的办公桌,我有了一个想法,我想到了一个解决办法。

    我在第一个函数中创建了另一个子ReportProcessingEventHandler。

    public void subReportProccessingFunc(object sender, SubreportProcessingEventArgs e)
    {
       sqls_Summary_Months.SelectParameters["LeaseID"].DefaultValue = 
       e.Parameters["prmLeaseID"].Values.First();
       e.DataSources.Add(new ReportDataSource("dsLeaseCalculationsMonths", 
       sqls_Summary_Months));
    
       this.rep_Main.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(subReportProccessingFunc1);
    }
    
    public void subReportProccessingFunc1(object sender, SubreportProcessingEventArgs e)
    {
       sqls_Summary_ViewMonth.SelectParameters["LeaseID"].DefaultValue = e.Parameters["prmLeaseID"].Values.First();
       sqls_Summary_ViewMonth.SelectParameters["Month"].DefaultValue = e.Parameters["prmMonth"].Values.First();
       e.DataSources.Add(new ReportDataSource("dsLeaseCalculationsViewMonth", sqls_Summary_ViewMonth));
    }
    

    因此,一旦第一个子报表被处理,第二个子报表将再次充当主报表,而另一个子报表将在其位置被处理。我可以为那一行选择prmMonth值,一切正常!