Skip to main content

DxGrid.KeyFieldNames Property

Specifies the names of data fields that contain key values. The combination of key values forms a unique identifier for a Grid data item.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.2.dll

NuGet Package: DevExpress.Blazor


public IReadOnlyList<string> KeyFieldNames { get; set; }

Property Value

Type Description

The list of key field names.


In common cases, a data object has a single key (a primary key). Use the KeyFieldName property to specify the key field name. If your data object has a compound key, use the KeyFieldNames property to specify key field names.

The Grid uses this field’s values to identify and compare data items. You should specify the KeyFieldNames (or KeyFieldName) property if the Grid in your application allows to perform the following actions:

If you do not specify key fields, the Grid uses standard .NET value equality comparison.

The code below specifies the OrderId and ProductId field values as keys for the OrderDetail data objects and enables row selection.

@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable

<DxGrid Data="GridDataSource"
        <DxGridDataColumn FieldName="OrderId" Caption="Order ID" DisplayFormat="d"/>
        <DxGridDataColumn FieldName="ProductId" Caption="Product ID" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c2" />
        <DxGridDataColumn FieldName="Quantity" />
        <DxGridDataColumn FieldName="Discount" />

<br />
    <b>Selected orders:</b>
    @foreach (var order in SelectedDataItems.Cast<OrderDetail>()) {
        <li>Order ID: @order.OrderId, Product ID: @order.ProductId</li>

@code {
    IEnumerable<object> GridDataSource { get; set; }
    NorthwindContext Northwind { get; set; }
    IReadOnlyList<object> SelectedDataItems { get; set; }

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        GridDataSource = Northwind.OrderDetails
        SelectedDataItems = GridDataSource.Skip(1).Take(2).ToList();

    IReadOnlyList<string> KeyFieldNames = new [] {

    public void Dispose() {

Key Field Names


See Also