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
.
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();
}
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
- How to show the ASPxGridView's detail information in the ASPxDataView
- How to display master-detail tables in two grids on separate tabs of a PageControl
- Grid View for ASP.NET Web Forms - How to Display a Popup Dialog When a User Clicks a Link in a Grid Row
- MVC Version: How to export multiple GridViews into a single print document
(you will be redirected to DevExpress.com to submit your response)