Skip to main content

ASPxGridBase.KeyFieldName Property

Gets or sets the name of the data source key field.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v22.1.dll

NuGet Package: DevExpress.Web


public string KeyFieldName { get; set; }

Property Value

Type Default Description
String String.Empty

A String value that specifies the name of the data source key field.


The KeyFieldName property should be specified when using the following grid features:

  • data editing;
  • adding new and deleting an existing data item (row, card or record);
  • selecting a data item (row, card or record);
  • master-detail view (for ASPxGridView);
  • endless paging.

The KeyFieldName property supports a composite value. You can use semicolon-separated values to specify multi-field keys, for example:

<dx:ASPxGridView ... KeyFieldName="FirstName;LastName;Phone;BirthDate">


  • The values contained in the key field must be unique.
  • It is not recommended that you use the DateTime column names in the KeyFieldName property value.
  • Negative key values are not supported in Batch Edit Mode. Instead, use a composite value.
  • A key field cannot contain values of a reference type (for instance, arrays).

The following code snippet illustrates how to select a row when a composite key is used.




For a full example, see the ASPxGridView - LargeDatabase (Server Mode) demo.

<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" KeyFieldName="ID"
    Width="100%" AutoGenerateColumns="False">
        <dx:GridViewDataTextColumn FieldName="From" Width="200px" />
        <dx:GridViewDataTextColumn FieldName="Subject" />
        <dx:GridViewDataDateColumn FieldName="Sent" Width="100px" />
        <dx:GridViewDataCheckColumn Caption="Attachment?" FieldName="HasAttachment" Width="100px" />
        <dx:GridViewDataTextColumn FieldName="Size" Width="80px">
            <Settings AllowAutoFilter="false" />
See Also