ActiveReports 18 .NET Edition
Report Authors: Designer Components / Data Binding / Data Binding in Page/RDLX Reports / Bind Nested Data Regions to Different Datasets
In This Topic
    Bind Nested Data Regions to Different Datasets
    In This Topic

    In Page and RDLX reports, you can use nested data regions that are bound to different datasets. To display data, you can either use a filter for a nested data region or a parameter that is set in the DataSetParameters property.

    Binding data regions to different data is available for all data regions that you can use in Page and RDLX reports, that is TablixListChartBandedListTable, and Sparkline.

    The report below shows the customer's contact name and phone information for products that are still in stock. The report layout consists of three nested Table data regions, each data region bound to a different dataset - Products (Table1), Invoices (Table2), and Customers (Table3).

    Nested Data Regions at design-time

    Nested Data Regions at run-time

    Using a filter

    To display data in nested data regions that are bound to different data, you can set a filter in the Table - Filters dialog. This filter will contain the value from a nested data region in the left side and the value from a parent data region in the right side of it.

    In the sample report above, two filters are created. For the Table2 data region bound to the Invoices dataset, we create the filter with the expression [ProductID]=[ProductID]. For the Table3 data region bound to the Customers dataset, we create the filter with the expression [CustomerID]=[CustomerID].

    As a result, the report shows the Product Name and Units In Stock information from the Products dataset. For each Product Name, the report shows the Customer Name information from the Invoices dataset and the Contact Name and Phone information from the Customers dataset.

    Using a parameter

    Setting a parameter in the DataSetParameters property also allows displaying data in nested data regions that are bound to different datasets. The basic steps are as follows.

    1. In the DataSetParameters property of a data region, add a new parameter, for example, productID.

      DataSetParameters Editor

    2. In the data region’s dataset, add a new parameter - productID.
    3. In the data region’s dataset, add a substring with the parameter to the existing dataset query, for example: WHERE productID = @productID
      DataSet - Query dialog box

    For the sample report layout above, two parameters are created. For the Table2 data region, bound to the Invoices dataset, we create the parameter productID and modify the dataset query as select * from Invoices where productID = @productID. For the Table3 data region, bound to the Customers dataset, we create the parameter customerID and modify the dataset query as select * from Invoices where customerID = @customerID.

    As a result, the report shows the Product Name and Units In Stock information from the Products dataset. For each Product Name, the report shows the Customer Name information from the Invoices dataset and the Contact Name and Phone information from the Customers dataset.

    See Also