Skip to Content
0
Former Member
Mar 18, 2015 at 03:15 PM

Adding multiple subreports from the same file to the same report

219 Views

I've created a report. This reports needs to have a number of charts. Each chart is the same report with different values for parameters.

The code works, except all charts reflect the parameter value provided to last call to SetParameterValue. How can I make sure each subreport behaves as a separate instance?

string chartReportPath = AppSettings.ReportsFolder + "ProgramCountry-Chart.rpt";

ReportClientDocumentWrapper doc = (ReportClientDocumentWrapper)report.ReportClientDocument;

string chartName = "Chart" + chartCount++;

CrystalDecisions.ReportAppServer.ReportDefModel.Section detailSection = doc.ReportDefController.ReportDefinition.DetailArea.Sections[0];

SubreportClientDocument subReport = doc.SubreportController.ImportSubreportEx(chartName, chartReportPath, detailSection,0,detailSection.Height+10,-1,-1);

ReportDocument subreportDoc = report.OpenSubreport(chartName);

report.SetParameterValue("@MyParam, myValue, chartName);