Master-Detail: Implementation

  • 2 minutes to read

In this document, you will learn how to use the Bootstrap Grid View to display master-detail data. Data is obtained from the Categories and Products tables in the NWind database. The Categories table is the master, while Products is a detail table. A master-detail relationship is established through the CategoryID field.

  1. Retrieve Data From the Database
  2. Create Master and Detail ASPxGridViews
  3. Set up a Master-Detail Relationship

1. Retrieve Data From the Database

To retrieve data from the database, use the SqlDataSource components:

  • Master: Categories


  • Detail: Products. Define a filter rule (see the image below).


2. Create Master and Detail ASPxGridView

Create two BootstrapGridView controls. Bind the first grid (master) to the dsCategories. Bind the second grid (detail) to the dsProducts. Specify data source key fields for both grids using their ASPxGridBase.KeyFieldName property.

3. Set up a Master-Detail Relationship

Invoke BootstrapGridView’s Template Designer by clicking the Edit Templates task. Select the DetailRow template.


Drag the detail grid onto the Detail Row template.


Handle the ASPxGridBase.BeforePerformDataSelect event to specify session values.

using DevExpress.Web.Bootstrap;

protected void detailGrid_BeforePerformDataSelect(object sender, EventArgs e) {
    Session["CategoryID"] = (sender as BootstrapGridView).GetMasterRowKeyValue();

When finished, select the End Template Editing task and enable the master grid’s ASPxGridViewDetailSettings.ShowDetailRow option.

The image below illustrates the result.