New to Telerik Reporting? Download free 30-day trial

Change Sub Report based on Main Report's Data

Environment

Product Progress® Telerik® Reporting
Report Item SubReport

Description

This article explains how to change the ReportSource of the SubReport based on Main Report's Data.

Solution

You can use a User Function in a Binding to the SubReport item's ReportSource property. The function should return a valid ReportSource object that wraps a report - the subreport.

For example, the following user function:

public static ReportSource SetReportSource(string field)
{
    var TRS = new TypeReportSource();
    TRS.Parameters.Add("Parameter1", field);
    if (field.ToLower() == "yes")
        TRS.TypeName = typeof(SubReport1).AssemblyQualifiedName;
    else
        TRS.TypeName = typeof(SubReport2).AssemblyQualifiedName;
    return TRS;
}

You should set the following Binding to the SubReport item in the Main report:

Property path: ReportSource

Expression: = SetReportSource(Fields.MainReportFieldX)

See Also

Extending Reporting Engine with User Functions

In this article