Skip to main content
A newer version of this page is available. .
Tab

ASPxGridView.GetMasterRowKeyValue() Method

Returns the master row’s key value.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

public object GetMasterRowKeyValue()

Returns

Type Description
Object

An object that uniquely identifies the master row.

Remarks

In master-detail scenarios, when ASPxGridView is used as a master grid that displays details within its detail rows, you can visualize detail data using any desired control. The main task in these scenarios is to identify a master row when a control that displays the details should be bound to its data.

GetMasterRowValues

If the ASPxGridView is used as a detail grid, its GetMasterRowKeyValue method is able to automatically identify the master row in which the detail grid’s instance is displayed. Use the GetMasterRowKeyValue method of a detail ASPxGridView within a handler of the detail grid’s data binding event (ASPxGridBase.BeforePerformDataSelect or DataBinding) to obtain the corresponding master row’s key value from a master ASPxGridView.


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

Example

This example demonstrates how to provide detail data on-the-fly. This is done by handling the detail grid's DataBinding event.See also:

How to use different components to display details of a master-detail ASPxGridViewHow to use different components to display details of a master-detail ASPxGridViewE3604: How to use different components to display details of a master-detail ASPxGridView

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.1" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v8.1" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Load detail data dynamically (self-referenced dataset example)</title>
</head>
<body>
    <form id="form1" runat="server">

    <div>
        <dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False"
            Width="511px">
            <Columns>
                <dxwgv:GridViewDataTextColumn FieldName="ID" VisibleIndex="0">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn FieldName="ParentID" VisibleIndex="1">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn FieldName="Name" VisibleIndex="2">
                </dxwgv:GridViewDataTextColumn>
            </Columns>
            <SettingsDetail ShowDetailRow="True" />
            <Templates>
                <DetailRow>
                    <dxwgv:ASPxGridView ID="ASPxGridView2" runat="server" AutoGenerateColumns="False"
            Width="511px" KeyFieldName="ID" OnDataBinding="ASPxGridView2_DataBinding">
            <Columns>
                <dxwgv:GridViewDataTextColumn FieldName="ID" VisibleIndex="0">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn FieldName="ParentID" VisibleIndex="1">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn FieldName="Name" VisibleIndex="2">
                </dxwgv:GridViewDataTextColumn>
            </Columns>
                        <SettingsDetail IsDetailGrid="True" />
        </dxwgv:ASPxGridView>
                </DetailRow>
            </Templates>
        </dxwgv:ASPxGridView>

    </div>
    </form>
</body>
</html>

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetMasterRowKeyValue() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also