Bind a Report to Multiple Data Tables
- 2 minutes to read
This tutorial illustrates the capability to include data from two (or more) non-linked data tables into a single report.
In this tutorial, the data tables are obtained from the same data source. To learn how to bind a report to different data sources, see Bind a Report to Multiple Data Sources.
To display multiple data tables in the same report document, do the following.
Create a new application or open an existing application. For more information, review the following help topic: Get Started with DevExpress Reporting.
- Add a new blank report to it.
Add a dataset to the project, which uses two non-linked tables, e.g., the “Employees” and “Products” tables of the sample Northwind database.
To add a DetailReportBand instance, right-click the Detail report band, and select Insert Detail Report | Unbound in the invoked popup menu.
Next, assign a data source to the created Detail Report. To do this, click the Detail Report’s smart tag, and in the invoked actions list, set the DataSource property to the required data source.
Likewise, define the band’s XtraReportBase.DataMember property to the “Employees” data table.
Right-click the Detail report band and select Insert Detail Report | Unbound in the invoked popup menu to create another DetailReportBand at the same level as the first Detail Report. Do not right-click on the previously created Detail Report band and select Insert Detail Report, because this creates the Detail Report nested, one level lower.
To force a page break between Detail Reports, set the Band.PageBreak property of the first DetailReportBand to AfterBand.
Finally, drag-and-drop the required data fields from the appropriate tables in the Field List onto the respective bands to create the bands’ actual content. For example:
The report is now ready. Switch to the Preview tab and view the result.