views:

5305

answers:

2

How can you programmatically set the parameters for a subreport? For the top-level report, you can do the following:

reportViewer.LocalReport.SetParameters
(
    new Microsoft.Reporting.WebForms.ReportParameter[]
    {
        new Microsoft.Reporting.WebForms.ReportParameter("ParameterA", "Test"),
        new Microsoft.Reporting.WebForms.ReportParameter("ParameterB", "1/10/2009 10:30 AM"),
        new Microsoft.Reporting.WebForms.ReportParameter("ParameterC", "1234")
    }
);

Passing parameters like the above only seems to pass them to the top-level report, not the subreports.

The LocalReport allows you to handle the SubreportProcessing event. That passes you an instance of SubreportProcessingEventArgs, which has a property of Type ReportParameterInfoCollection. The values in this collection are read-only.

+1  A: 

Add the parameter to the parent report and set the sub report parameter value from the parent report (in the actual report definition). This is what I've read. Let me know if it works for you.

benjynito
A: 

set the parameter to <Expression...> and use formula builder to add the parent parameter.

abmaheco