Skip to main content

Grid displays empty rows in database server mode

When GridView extension is bound in database server mode it may display a set of empty rows and a correct pager.

This behavior occurs when an underlying data source executes several queries to get data. While the pager request may pass, the data query can fail because the column used a key expression that contains non-unique values. As a result, the pager and related number of records are displayed correctly, but there is no data in these cells.

To resolve this issue, you need to get information about the exception. Handle the following events to obtain internal exception details (if any):

  • The ServerExceptionThrown event for XPServerCollectionSource.

  • The ExceptionThrown and InconsistencyDetected events for LinqServerModeDataSource or EntityServerModeDataSource.

    @Html.DevExpress().GridView(settings => {  
        // GridView settings  
    }).BindToEF("", "", (s, e) => {  
        // Specify queryable source  
        e.QueryableSource = ContextInstance.DbSetTable;  
        e.KeyExpression = "KeyColumnOrExpression";  
    }, (s, e) => {  
        // Handle internal exception  
        ViewContext.Writer.Write(e.Exception.Message + Environment.NewLine + e.Exception.StackTrace);  
    }).GetHtml()  
    

You can use recommendations from the following article to see all exceptions and obtain details required for diagnostic: Obtain an Exception's Call Stack in Visual Studio