I have a configurable win forms app in which I can set how much times a subreport can be inserted into main report like this:
Config page: (order of importing subreports)
SubRep1 SubRep1 SubRep1 SubRep3 SubRep3 SubRep2 SubRep2 SubRep2
So, in my main report I will import/insert 3 times subreport 1, 2 times subreport 2 and 3 times subreport 2. Each subreport has a one parameter and I set through code a value, but it only appears on the first instance of the report...
So, like this:
SubRep1 (has a parameter) SubRep1 SubRep1 SubRep3 (has a parameter) SubRep3 SubRep2 (has a parameter) SubRep2 SubRep2
The problem is that I need to have a parameter for each one! My code...
SetMainReportParameters(reportParameterList);
for (int i = 0; i < rlc.ReportLayout.Count; i++)
{
if (rlc.ReportLayout[i].SubreportName == "SectionReportTest1.rpt")
{
SetSectionOneReportParameters(reportParameterList);
}
if (rlc.ReportLayout[i].SubreportName == "SectionReportTest2.rpt")
{
SetSectionTwoReportParameters(reportParameterList);
}
if (rlc.ReportLayout[i].SubreportName == "SectionReportTest3.rpt")
{
SetSectionThreeReportParameters(reportParameterList);
}
}
and when passing...
//list of every parameter (main and subreports)
foreach (var current in reportParameterList)
{
if (string.IsNullOrEmpty(current.SubreportName))
{
document.SetParameterValue(current.Name, current.Value);
}
else
{
document.SetParameterValue(current.Name, current.Value, current.SubreportName);
}
}