【发布时间】:2019-03-10 22:22:20
【问题描述】:
我正在构建一个用户可以导出的报告,但我遇到了一些困难。我很想得到一些人的意见,因为我开始有点灰心了。
问题
我有 CalcTable 存储 CalcTableMonthly 的父行。要从CalcTable 检索行,我使用标识符LeaseID。然后由于CalcTable 中有多个行在一个LeaseID 之下,CalcTable 中的每一行将在CalcTableMonthly 中有多个月度值。
MainReport 通过LeaseID 从CalcTable 获取值。
SubReport1 再次通过LeaseID 从CalcTableMonthly 获取值。这些值是在CalcTableMonthly 中具有值的所有可用CalcTable 行的组合。
然后最后SubReport2 获取该月的所有组合值。所以我必须从 SubReport1 中传入LeaseID 和Month。
所以你可以看到它在第 2 级时有效。
页面加载
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 =我不确定如何处理。如何从 RDLC 报告的当前行中检索月份?
我尝试过的事情
- 谷歌搜索类似问题,找不到任何东西
- 将 DefaultValue 设置为
e.Parameters["LiabilityDate"].Values.First()不起作用,因为它没有获取值。
就是这样,因为我真的不知道......
总结
我有 1 个主报表,该主报表有一个子报表,该子报表有另一个子报表。为了检索子报表,我只将 LeaseID 值传递给它。第一个子报表也只需要 LeaseID 但是位于第一个子报表中的第二个子报表需要 LeaseID AND月份。我不确定如何在 RDLC 的子报表中获取本月变量,因为它在报表生成器中的 rdl 中工作,如下图所示,但遗憾的是当我在 ASP.net 中使用它时无法工作
【问题讨论】:
标签: c# asp.net reporting-services ssrs-2008 rdlc