Skip to content

DevExpress-Examples/aspxgridview-show-detail-information-in-separate-grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for ASP.NET Web Forms - How to Show Detail Information in a Separate Grid

This example demonstrates how to use two ASPxGridView instances to show master-detail data. When a user selects a row in the master ASPxGridView, detail data is displayed in another ASPxGridView.

Two grids that show master-detail data

Once a focused row is changed in the master grid, its FocusedRowChanged event is raised. The FocusedRowChanged event handler calls the detail grid's PerformCallback method to send a callback to the server:

function UpdateDetailGrid(s, e) {
    detailGridView.PerformCallback();
}
 <dx:ASPxGridView ID="gvMaster" runat="server" 
                  ClientInstanceName="masterGridView"
                  KeyFieldName="CategoryID">            
    <SettingsBehavior AllowFocusedRow="True" AllowClientEventsOnLoad="False" />
    <ClientSideEvents FocusedRowChanged="UpdateDetailGrid" />
</dx:ASPxGridView>

<dx:ASPxGridView ID="gvDetail" runat="server" 
                 ClientInstanceName="detailGridView" 
                 KeyFieldName="ProductID"
                 OnCustomCallback="gvDetail_CustomCallback">
</dx:ASPxGridView>

On the server, the PerformCallback method raises the CustomCallback event. The CustomCallback event handler establishes a master-detail relationship through the CategoryID field and updates the detail grid's data:

protected void gvDetail_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e) {
    string categoryId = gvMaster.GetRowValues(gvMaster.FocusedRowIndex, "CategoryID").ToString();
    adsProducts.SelectParameters["CategoryID"].DefaultValue = categoryId;
    gvDetail.DataBind();
}

Files to Look At

Documentation

More Examples

Does this example address your development requirements/objectives?

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