aspnetmvc-14760-components-grid-view-binding-to-data-binding-to-large-data-database-server-mode.md
The MVC GridView extension supports a specific binding mode designed to work with large datasets. Within this binding mode, data-aware operations (sorting, grouping, etc.) are performed on the database server side, which is why this mode is called database server mode.
In database server mode, the MVC GridView is bound to a queryable source via the GridViewExtension.BindToLINQ method, which allows the GridView to load data from the queryable source on demand.
When an end-user performs data operations (sorting, grouping, etc.), the GridView generates smart queries to receive only those records that must be displayed on screen. These requests are passed to the associated queryable source. The queryable source translates these requests into the required queries and executes them. This ensures a quick response and improved performance for large data sources.
For end-users, the MVC GridView functions identically in regular and server modes. In database server mode , end-users can use an automatic filtering feature to access a particular data range, sort, group and filter data, calculate summaries, etc.
Perform the following steps to bind the GridView to a data source in database server mode.
Add the GridView to your project
Change the View code
Change the Controller code
In server mode, the MVC GridView does not have simultaneous access to bound data in its entirety. This imposes some limitations on the grid’s features that are still available in regular binding mode. see the table below for information on features that have limitations in server mode:
Custom sorting (via GridViewSettings.CustomColumnSort) and sorting by displayed values are not supported.
Custom grouping (via GridViewSettings.CustomColumnGroup) is not supported.
Filtering by displayed values is not supported. Only filtering by edit values is allowed.
Case-sensitive filtering. The grid converts a search string to lower-case before filtering.
Custom summary calculation (via GridViewSettings.CustomSummaryCalculate) is not supported.
You can only enable sorting, grouping, filtering and summary calculation for unbound columns that are populated using expressions (see GridViewDataColumn.UnboundExpression).
The grid does not support selection of all grid rows with the “SelectAll” check box (when the GridViewCommandColumn.SelectAllCheckboxMode property is set to GridViewSelectAllCheckBoxMode.AllPages). In this scenario, you can set the SelectionStoringMode property to “PerfomanceOptimized” to make the grid add only unselected row keys when a user selects all rows.
View Example: How to bind grid to Entity Framework in regular and database server modes
See Also
Grid View - Data Binding to Large DatabaseOnline demo: