The requested page is not available for the requested platform. You are viewing the content for Default platform.

Bind a Report to Multiple Data Tables

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. Start Microsoft Visual Studio 2010, 2012, 2013, 2015 or 2017 and create a new application under any of the supported platforms, or open an existing one.
  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

    As shown in the above image, the XRLabel in the first Detail Report is used to display data from two fields simultaneously. To learn how this is achieved, refer to Create a Letter.

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

HowTo_DisplayMultipleTables_6

See Also