How to: Use the XRSubreport Control with Reports V2 Data Sources

This topic describes the specifics of using the XRSubreport control when creating a Master-Detail Report with Data Sources for Reports V2 (CollectionDataSource or ViewDataSource).

Note

The approach described in this topic is not supported by the Mobile platform.

XRSubreport and CollectionDataSource

To create a report with a subreport in XAF, you can follow the Creating a Master-Detail Report using Subreports tutorial published in the XtraReports documentation, but using the CollectionDataSource instead of binding to data directly. Then, you can register a master report using the PredefinedReportsUpdater.AddPredefinedReport<T> method. No additional steps are required.

XRSubreport and ViewDataSource

Note

The complete example is available in the FeatureCenter application. By default, this demo is installed in the %PUBLIC%\Documents\DevExpress Demos 18.2\Components\eXpressApp Framework\FeatureCenter path. The master report and its subreport are demonstrated in the following files.

  • FeatureCenter.Module\Reports\ContactReport.cs
  • FeatureCenter.Module\Reports\PhoneNumberReport.cs

If you choose ViewDataSource, use the same approach described in the previous paragraph, but take into account that the master object's key column is added in the Parameter Bindings Collection Editor dialog demonstrated in the XtraReports tutorial. With the ViewDataSource, you should add the key column manually to the ViewDataSource.Properties collection. The Expression value should refer to the key property of the business class specified by DataSourceBase.ObjectTypeName (e.g., to the BaseObject.Oid property). The image below demonstrates the key column added in the Reports Designer.

ReportsV2_Subreport_ViewDataSource_Oid