Skip to main content
All docs
V25.1
  • The 'Key expression is undefined' error occurs when you use GridViewExtension.BindToLINQ / GridViewExtension.BindToEF methods

    Error Description:

    This error can occur when the GridViewExtension.BindToLINQ and GridViewExtension.BindToEF methods cannot automatically recognize the key (unique) column from the TableName or QueryableSource specified at runtime.

    Solution:

    Do the following to resolve this issue:

    • Use the GridViewExtension.BindToLINQ/GridViewExtension.BindToEF methods (MVC).

    • Specify the e.KeyExpression property.

    @Html.DevExpress().GridView(  
        settings => {  
        ...  
    }).BindToLINQ(string.Empty, string.Empty, (s, e) => {  
        ...  
        e.KeyExpression = UNIQUE_KEY_COLUMN_NAME;  
    }).GetHtml()  
    
    @Html.DevExpress().GridView( _  
        Sub(settings)  
            ...  
    End Sub).BindToLINQ(String.Empty, String.Empty,  
    New EventHandler(Of DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs)( _  
    Sub(s, e)  
            ...  
            e.KeyExpression = UNIQUE_KEY_COLUMN_NAME  
    End Sub)).GetHtml()