Bind a Report to Multiple Data Tables
- 3 minutes to read
This tutorial shows you step-by-step how to include data from two (or more) unrelated data tables in a single report. In this topic, the data tables are from the same data source. For information on how to bind a report to different data sources, review the following help topic: Bind a Report to Multiple Data Sources.
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, as described in the following help topic: Create a Report in Visual Studio.
Add a data source with two unrelated tables. You can use the Employees and Products tables from the sample Northwind database. For more information on how to add a data source to the report, review the following help topic: Bind a Report to a Database.
Clear the DataSource and DataMember settings for the report. The settings should be assigned individually to the Detail Report bands, as described later.
Add a new Detail Report band. To do this, right-click on the Detail report band and select Insert Detail Report | Unbound in the context menu:
Specify the
sqldataSource1
data source andEmployees
data member for the created DetailReport band:Add another new Detail Report band. To do this, right-click the Detail report band and select Insert Detail Report | Unbound in the context menu to create another DetailReportBand at the same level as the first Detail Report band.
Do not right-click a previously created Detail Report band and select Insert Detail Report, as this action creates a nested Detail Report band one level lower.
Specify the
sqldataSource1
data source andProducts
data member for the second DetailReport band:To force a page break between different data sets in a report, set the Band.PageBreak property of the first DetailReportBand to
AfterBand
:Drag the
FirstName
andLastName
fields from theEmployees
table in the Field List, and drop them onto the first Detail Report band:Drag the
ProductName
field from theProducts
table in the Field List and drop it onto the first Detail Report band:Switch to the Preview tab and view the result.
When you create a reporting application, you might need to modify or configure data sources for your reports at runtime. Refer to the following topic for more information: Manage Data Sources at Runtime.