[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Collapse]Grid View
    Overview - GridView
    Main Features - GridView
    [Collapse]Binding to Data
      Binding to Data via Entity Framework (Code First)
      Binding to Data via Entity Framework or LINQ to SQL (Database First)
      Binding to Large Data (Database Server Mode)
     [Collapse]Custom Data Binding
       Custom Data Binding - Overview
       Action Types and Passed Parameters
       Methods to Update the Grid State in Actions
       ProcessCustomBinding - Available Binding Delegates
       Implementation of Typed Method Delegates
       Custom Binding Limitations
    [Expand]Data Representation Basics
    [Expand]Data Shaping and Manipulation
    [Expand]Focus and Navigation
    [Expand]Data Editing and Validation
   [Expand]Visual Elements
   [Expand]Member Tables
  [Expand]Tree List
  [Expand]Card View
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors Extensions
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Extensions
  [Expand]Query Builder
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Custom Data Binding - Overview

GridView supports custom data binding that allows you to provide the grid with data manually. In this custom data binding mode, you have full control of and responsibility for populating the grid with the required data each time the grid requests it.


The Custom Data Binding mode was specially designed for working with a large data volume and handling all data shaping operations manually (e.g., it is impossible to use the built-in Linq/Entity Framework capabilities for some reason).

If there are no strict requirements to use the Custom Data Binding, it is recommended to use one of the following data binding modes.

In brief, this mode requires that you manually populate a grid-specific view model with a portion of data that needs to be currently displayed within the grid. You can accomplish this by performing the following steps.

  • Define Handling Actions
    In addition to a standard handling Action defined via the GridSettingsBase.CallbackRouteValues, use the GridViewSettings.CustomBindingRouteValuesCollection to specify additional Actions to handle all or particular grid data operations (Paging, Filtering, Sorting and Grouping), depending upon which functionality is used in your grid. Data operations are identified by the GridViewOperationType enumeration values.

  • Obtain/Update Grid State
    In Actions, use the GridViewExtension.GetViewModel static method to obtain the grid's view model, which is a specific GridViewModel object designed to maintain the grid state and provide a means to populate itself with data. By default, the view model obtained within Actions contains the previous state of the grid. If required, update this state with the state information that relates to the processed operation and is automatically passed to an Action as a parameter. (For instance, this state can be a column state (GridViewColumnState) that contains information on which column is sorted/grouped and in which direction/order, or a pager state (GridViewPagerState) that determines which page is selected.)

  • Delegate Model Population
    Within a Controller, use the grid view model that contains the up-to-date grid state and call its GridViewModel.ProcessCustomBinding method to delegate the implementation of a model population to certain Model-layer functions specified via method parameters.

  • Implement Model Population
    At the Model layer, implement certain delegates, which are pointed to by the ProcessCustomBinding method's parameters to populate the grid view model with a portion of the currently required data.

  • Bind the Grid to the Populated Model
    In a Controller, pass the populated view model object as a Model to the grid's Partial View. In the Partial View, bind the grid to the passed Model by using the GridViewExtension.BindToCustomData method.


When implementing the grid's custom data binding, the DevExpressEditorsBinder must be used instead of the default model binder to correctly transfer values from DevExpress editors back to the corresponding data model fields. See the Binding to Model section in the Binding Data Editors to Data topic for more details on how to specify DevExpressEditorsBinder as a model binder.

These steps are described in greater detail below. Note that the code samples provided in this topic cover a simple custom data binding scenario. In this scenario, only paging and sorting operations are available within the grid, and are handled within Actions. Also, only required delegate methods are implemented in a Model. You can refer to the following demos to see this scenario and a more complex binding scenario in action.

You can also make use of the following code samples to start implementing your custom binding scenario.

Expanded Define Handling Actions

To associate a grid data operation type with a handling Action method, populate the grid's specific route values collection available via the GridViewSettings.CustomBindingRouteValuesCollection property. Register each data operation that you need to handle by adding a specific item to the collection. Within an item, identify a grid data operation and specify a handling method by providing its Controller and Action names.

Partial View Code:

Refer to the Action Types and Passed Parameters topic to learn more on available data operation types.

Expanded Obtain/Update Grid State

In each specified Action, you can obtain both the previous state of the grid (the state the grid had before an end-user performed the currently processed data operation) and the information (state) specific to the currently processed operation (for instance, information about the applied paging or sorted/grouped column). The grid's previous state can be obtained as a grid view model object (GridViewModel) by making a call to the static GridViewExtension.GetViewModel method. The currently processed data operation's state is automatically passed to each Action as its parameter(s). You can update the grid view model object, maintaining the previous grid state with the state of the currently processed operation to update the grid state. Then, the updated grid view model should be processed to populate it with the required data (see the next item for details).

Controller Code:

Refer to the Action Types and Passed Parameters topic to learn more on operation-specific parameters passed to handling Actions automatically.
See the Methods to Update the Grid State in Actions topic for a list of methods the GridViewModel exposes to update the grid state.

Expanded Delegate Model Population

Given the grid view model, call its GridViewModel.ProcessCustomBinding method to delegate the implementation of model population to certain Model-layer functions specified via the method's parameters. The GridViewModel.ProcessCustomBinding method has several overloads. You can select one depending on which data operations you need to handle.

Controller Code:
Sample Model Code:

Refer to the ProcessCustomBinding - Available Binding Delegates topic to learn more on the ProcessCustomBinding method.

Expanded Implement Model Population

At the Model layer, provide implementation for the specified method delegates according to your application needs and domain layer logic. Use arguments available through the e parameter of method delegates to obtain operation-related information and to supply the model with the required data.

Model Code:

Refer to the Implementation of Typed Method Delegates topic to learn more on the available arguments and the implementation of method delegates.

Expanded Bind the Grid to the Populated Model

The resulting populated grid view model object should be returned as a Model to a Partial View that contains the GridView markup. To bind the GridView to this view model, use the GridViewExtension.BindToCustomData method within the grid's Partial View.

Controller Code:
Partial View Code:

Is this topic helpful?​​​​​​​