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

ASPxGridView.GetDetailRowKeyValue(Control) Method

Gets the key value of the grid’s row that is the master row for the specified control used to display detail data.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.1.dll

Declaration

public static object GetDetailRowKeyValue(
    Control control
)

Parameters

Name Type Description
control Control

A control that represents detail data.

Returns

Type Description
Object

An object that uniquely identifies the master row containing the specified detail control.

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 primary task in these scenarios is to identify a master row when a control that displays the details should be bound to its data.

GridView-GetDetailRowKey

If a detail control is not ASPxGridView, you can use a master grid’s GetDetailRowKeyValue method to determine in which master row the specified detail control is currently instantiated. This method accepts a detail control instance as a parameter and returns the corresponding master row’s key value.

protected void GridView1_DataBinding (object sender, EventArgs e) {
        //Standard GridView is used as a detail control.
        GridView detailGrid = sender as GridView;
        detailGrid.DataSource = dsDetailView;
        dsDetailView.SelectParameters["CategoryID"].DefaultValue = ASPxGridView.GetDetailRowKeyValue(detailGrid).ToString();
    }

Example

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.The simplest way to visualize detail data is to use ASPxGridView, because this control has the GetMasterRowKeyValue method that automatically obtains the corresponding master row's key value from a master ASPxGridView.For other cases (when a detail control is not ASPxGridView), you can bring a detail control in correlation with its master row by using a specifically implemented static method - ASPxGridView.GetDetailRowKeyValue. This method accepts a detail control instance as a parameter and returns the corresponding master row's key value: GetDetailRowKeyValue(Control)

This example demonstrates how to use the GetMasterRowKeyValue and ASPxGridView.GetDetailRowKeyValue methods.

object keyValue = ASPxGridView.GetDetailRowKeyValue(treeList);
Dim keyValue As Object = ASPxGridView.GetDetailRowKeyValue(treeList)

See also:

using DevExpress.Web.ASPxTreeList;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.ASPxEditors;

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load (object sender, EventArgs e) {
    }

    protected void ASPxTreeList1_Init (object sender, EventArgs e) {
        ASPxTreeList treeList = sender as ASPxTreeList;
        object keyValue = ASPxGridView.GetDetailRowKeyValue(treeList);
        if (keyValue.Equals(2) || keyValue.Equals(5))
            treeList.RootValue = keyValue;
    }

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

    protected void GridView1_DataBinding (object sender, EventArgs e) {
        GridView gridView = sender as GridView;
        gridView.DataSource = dsDetailView;
        dsDetailView.SelectParameters["CategoryID"].DefaultValue = ASPxGridView.GetDetailRowKeyValue(gridView).ToString();
    }
}
See Also