Skip to main content

Bind Grid View to Large Data (EF)

  • 3 minutes to read

ASPxGridView supports binding to large data sets via the EntityServerModeDataSource component. This component fully supports database server mode (i.e., it delegates all data processing to the DB server), and loads the minimum required amount of records to be displayed on the screen. This allows you to dramatically increase performance when working with large datasets.

You can enable server mode for any Entity Framework (EF) Data Model. The EntityServerModeDataSource component is designed for ASP.NET applications, and serves as the data source for the ASPxGridView control.

When a user performs data operations (such as sort or group actions), the EntityServerModeDataSource component analyzes the grid’s current state and generates smart queries to receive only those records that must be displayed on-screen. These requests are passed to the associated EF Data Model. The EF Data Model translates these requests into the required queries and executes them.

Note

The EntityServerModeDataSource component is a read-only data source (for Entity Framework version 4.1 and above) that has a DbContext object instead of an ObjectContext object for older versions. Thus, the ASPxGridView’s built-in insert, edit, and delete operations are not available if you use Entity Framework version 4.1 and above.

To enable data modification operations, handle the corresponding ASPxGridView events manually (ASPxGridView.RowUpdating, ASPxGridView.RowInserting, and ASPxGridView.RowDeleting, respectively). See the following example to learn how to handle these events: How to implement common scenarios within a grid bound with Entity Framework 6.

Example

The EntityServerModeDataSource component allows you to bind ASPxGridView to the ADO.NET Entity Data Model and enable database server mode.

Create Data Classes

  1. Add the ADO.NET Entity Data Model. ASP.NET_Grid_ServerMode_EF

  2. Follow the wizard’s steps to generate a new data model using the code-first or database-first development approach.

  3. Save the generated model, close the EDMX diagram, and build the solution.

Connect to the Data Model using the EntityServerModeDataSource control

  1. Drag the EntityServerModeDataSource component from the Visual Studio toolbox and drop it onto the ASPX Page.

  2. Use the EntityServerModeDataSource.ContextTypeName property to specify the data context type name.

  3. Use the EntityServerModeDataSource.TableName property to specify the data table name.

  4. Bind the ASPxGridView control to the EntityServerModeDataSource component and specify the grid’s ASPxGridBase.KeyFieldName property.

Database Server Mode Limitations

In database server mode, ASPxGridView does not have simultaneous access to bound data in its entirety. This imposes some limitations on the grid’s features, which are still available in regular binding mode. See the following topic for information on features that are not supported in server mode: Database Server Mode Limitations.

See Also