Skip to main content
A newer version of this page is available. .

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.

Tip

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.

  1. Create a new application or open an existing application.

  2. Add a new blank report to it.
  3. Add a dataset to the project, which uses two non-linked tables, e.g., the “Employees” and “Products” tables of the sample Northwind database.

    HowTo_DisplayMultipleTables_0

    Note

    Make sure that data source of the report itself is not assigned. If it is not empty, you should manually reset the report’s XtraReportBase.DataSource and XtraReportBase.DataMember properties, since similar properties are to be assigned individually for the DetailReportBands.

  4. To add a DetailReportBand instance, right-click anywhere over the report’s surface, and select Insert Detail Report | Unbound in the invoked popup menu.

    HowTo - BindReportToDifferentDataSources_0

  5. 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.

    HowTo_DisplayMultipleTables_2a

  6. Likewise, define the band’s XtraReportBase.DataMember property to the “Employees” data table.

    HowTo_DisplayMultipleTables_2b

  7. In a similar way, create another DetailReportBand (it should be created at the same level as the first Detail Report, and not nested into it).

    HowTo_DisplayMultipleTables_3

  8. To force a page break between Detail Reports, set the Band.PageBreak property of the first DetailReportBand to AfterBand.

    HowTo_DisplayMultipleTables_4

  9. 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:

    HowTo_DisplayMultipleTables_5

    Note

    In the above image, the XRLabel in the first Detail Report is used to display data from two fields simultaneously. To do this, refer to the Letters tutorial.

The report is now ready. Switch to the Preview tab and view the result.

HowTo_DisplayMultipleTables_6

See Also