| title | Change Sub Report based on Main Report's Data |
|---|---|
| description | Edit Sub Report based on Main Report's Data. |
| type | how-to |
| page_title | Modify Sub Report based on Main Report's Data |
| slug | change-sub-report-based-on-main-report-s-data |
| res_type | kb |
| Product | Progress® Telerik® Reporting |
| Report Item | SubReport |
This article explains how to change the ReportSource of the SubReport based on Main Report's Data.
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)
Extending Reporting Engine with User Functions