Bind a Report to Multiple Data Sources
- 2 minutes to read
You can bind the following report elements to data sources other than the report’s data source:
This topic shows how to bind two DetailReport bands to different data sources. Follow the steps outlined below.
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 DetailReport band to the report: select Insert Detail Report/Unbound in the context menu:
Bind the added band to a data source. Click the smart tag, expand the Data Source drop-down list, and click Add Report Data Source.
The invoked Data Source Wizard guides you through the process of assigning the data source to the band. These steps are similar to the ones described in the following topic: Bind a Report to a Database.
In this example, bind the Detail Report band to the Employees table from the sample Northwind database.
Once you complete the above steps, the DetailReport band’s DataSource property is set to sqlDataSource1. Then set the band’s DataMember property to the dataset’s Employees table.
Create another Detail Report band at the same detail level. To do so, right-click the report design area outside the previously created Detail Report band and select Insert Detail Report/Unbound in the context menu. Review this newly created DetailReport band in the following image:
Proceed with the same steps as described above to bind the second Detail Band to a different data source. In this example, the second data source is the Northwind database’s Suppliers table:
In this example, you do not need to show any data in the Detail band. Set the Detail band’s Visible property to False to hide it:
Insert a Report Header band into each Detail Report band:
Add label controls to report header bands. Drop data fields from the Field List onto detail report bands:
The report is ready. Switch to the Preview tab and view the result.
Tip
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.