Skip to main content
All docs
V24.2

A primary key field specified using the KeyFieldName property is not found

  • 2 minutes to read

Error Description

The error can occur when you use the following controls/extensions:

Solution

Check whether the KeyFieldName property is specified if you use the following ASPxGridView features:

  • Editing.
  • Selection.
  • Master Detail.
  • Endless Paging.

Try one of the following suggestions to overcome this issue:

  1. A data source does not contain a field specified in the KeyFieldName property. Make sure the field name is spelled correctly and in the correct case.

  2. The field is not marked with the “public” keyword or does not have “get”/“set” accessors. You should implement the “get”/“set” accessors for the fields/properties you use;

  3. The data source fields were changed and do not contain this field. You should update the ASPxGridView.KeyFieldName property to reflect the changes made to the data source.

  4. The data source does not contain data records, and ASPxGridView cannot map the schema of data records. Handle the ASPxGridView.DataBinding event and specify the data record type (ForceDataRowType(Type)).

    <dx:ASPxGridView ... OnDataBinding="grid_DataBinding">  
    </dx:ASPxGridView>  
    
    protected void grid_DataBinding(object sender, EventArgs e) {  
        (sender as ASPxGridView).ForceDataRowType(typeof(DATA_RECORD_TYPE_HERE));  
    }  
    
  5. The ASPxGridView control is incorrectly bound to its data source. See also: Bind Grid View to Data at Runtime.

  6. Set the EnableRowsCache property to false.