/asp-net-web-forms-grid-master-detail-implementation

Use a detail row template to display master-detail data.

Primary LanguageASP.NETOtherNOASSERTION

Grid View for ASP.NET Web Forms - Simple master-detail implementation

This example demonstrates how to use a detail row template to display master-detail data.

Master-Detail Implementation

Overview

Follow the steps below to enable the master-detail functionality:

  1. Create a master Grid View control, bind it to a data source, and enable the grid's ShowDetailRow property.

    <dx:ASPxGridView ID="masterGrid" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSourceCustomers" KeyFieldName="CustomerID" ... >
        <!-- ... -->
        <SettingsDetail ShowDetailRow="True" />
    </dx:ASPxGridView>
  2. Specify the master grid's GridViewTemplates.DetailRow property and add a detail grid to the template. Bind the detail grid to a data source and handle the grid's server-side BeforePerformDataSelect event. In the handler, call the grid's GetMasterRowKeyValue method to obtain the key value of the corresponding row in the master grid.

    <Templates>
        <DetailRow>
            <dx:ASPxGridView ID="detailGrid" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSourceOrders"
                KeyFieldName="OrderID" OnBeforePerformDataSelect="detailGrid_BeforePerformDataSelect" ... >
                <!-- ... -->
            </dx:ASPxGridView>
        </DetailRow>
    </Templates>
    protected void detailGrid_BeforePerformDataSelect(object sender, EventArgs e) {
    	Session["CustomerID"] = (sender as ASPxGridView).GetMasterRowKeyValue();
    }
  3. Handle the grid's server-side RowDeleting, RowInserting, and RowUpdating events to configure the grid's edit functionality.

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)