Skip to main content

GridViewSelection.SelectRowByKey(Object) Method

Selects the row specified by the key value.

Namespace: DevExpress.Web.Data

Assembly: DevExpress.Web.v22.1.dll


public void SelectRowByKey(
    object keyValue


Name Type Description
keyValue Object

The row’s key value.


Use the SelectRowByKey and UnselectRowByKey(Object) methods to select and deselect the row specified by the key value.

For more information on row selection in the grid, refer to the following topic: Selection.

The code sample below gets the current selection state of the row with the specified key value and changes it.

<dx:ASPxGridView ID="gridview" ClientInstanceName="grid" runat="server" AutoGenerateColumns="False"
    KeyFieldName="ProductID" OnCustomCallback="gridview_CustomCallback">
        <dx:GridViewCommandColumn ShowSelectCheckbox="true" VisibleIndex="0" />
<br />
<dx:ASPxButton ID="ASPxButton1" runat="server" Text="Change selection state" AutoPostBack="false">
    <ClientSideEvents Click="onButtonClick" />
function onButtonClick(s, e) {
protected void gridview_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
    var grid = sender as ASPxGridView;
    var rowKey = 6;
    if(grid.Selection.IsRowSelectedByKey(rowKey)) {
    } else {

Select the Row Specified by the Composite Key Value

<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" KeyFieldName="ProductID;ProductName">
See Also