I am building a report that the user can export and I am running in to some difficulties. I would love some input from somebody as I am starting to grey a little.
I have CalcTable
that stores parent rows for CalcTableMonthly
. To retrieve rows from CalcTable
I use identifier LeaseID
. Then due to there being multiple rows in CalcTable
under one LeaseID
and each one row in CalcTable
will have multiple monthly values in CalcTableMonthly
.
The MainReport
gets the values from CalcTable
via the LeaseID
.
The SubReport1
gets values from the CalcTableMonthly
via again the LeaseID
. These values are a combination of all available CalcTable
rows that have values in CalcTableMonthly
.
Then Finally SubReport2
gets all of the combined values for that month. So I must pass in the LeaseID
and Month
from SubReport1.
So you can see that it works as far as level 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));
}
From the above code the line sqls_Summary_ViewMonth.SelectParameters["Month"].DefaultValue =
I am unsure how to handle. How can I retrieve the month from the current row in the RDLC report?
e.Parameters["LiabilityDate"].Values.First()
, did not work as it was not picking up the value.That is about it since I really have no idea...
I have 1 main report, that main report has a subreport which has another subreport. To retrieve the subreport I pass the LeaseID value only to it. The first subreport also only requires LeaseID BUT second subreport that is located withing first subreport requies the LeaseID AND the month. I am unsure how I can get this month variable in the subreport in RDLC as it works in rdl in report builder as seen by the image below but sadly does not work when I use it in ASP.net
Well after some tinkering and walking away from my desk I had a think and I thought of a solution.
I created another SubreportProcessingEventHandler within the first function.
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));
}
So once the first subreport is processed the second one acts like a main report again and another sub report is processed in its place. I was able to select the prmMonth value for that row and it all worked!
Hope it helps anyone that stumbles upon this!