[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [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
    Main Features
   [Collapse]Concepts
    [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
       Action Types and Passed Parameters
       Methods to Update the Grid State in Actions
       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]Exporting
   [Expand]Visual Elements
   [Expand]Member Tables
   [Expand]Examples
  [Expand]Tree List
  [Expand]Card View
   Reporting
  [Expand]Charting
  [Expand]Pivot Grid
   Spreadsheet
   Rich Text Editor
  [Expand]Scheduler
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Extensions
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]Localization
 [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]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[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

In custom data bind mode, you can populate a grid's view model with data each time the grid requests it.

Follow the steps below to use custom logic to bind the grid to data:

  1. Handle Grid Data Operations

  2. Obtain/Update Grid State

  3. Populate the Grid Model

  4. Bind the Grid to the Populated Model

<a name="actions">

Expanded 1. Handle Grid Data Operations

The following properties allow you to specify the grid's route values collection to handle grid data operations (filtering, sorting, grouping, paging, etc.):

Use the GridViewOperationType enumeration values to identify grid data operations.

Partial View Code:

Refer to the Action Types and Passed Parameters topic for more information about the available data operation types.

<a name="state">

Expanded 2. Obtain/Update Grid State

Use the GridViewExtension.GetViewModel method to obtain the grid's view model (GridViewModel) that stores the grid's previous state (for example, the GridViewColumnState) and the (GridViewPagerState) objects). The controller's actions get the current grid state as a parameter.

Controller Code:

See also:

<a name="populate">

Expanded 3. Populate the Grid Model

In the controller, use the grid's view model (GridViewModel) and call its GridViewModel.ProcessCustomBinding delegate method to populate the grid's model with the requested data.

Controller Code:

Model Code:

See also:

<a name="bind">

Expanded 4. Bind the Grid to the Populated Model

In the controller, pass the populated grid's model as a model to the grid's Partial View. In the Partial View, use the GridViewExtension.BindToCustomData method to bind the grid to the passed model.

Note

In custom data bind mode, use the DevExpressEditorsBinder object instead of the default model binder to 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 information.

Controller Code:

Partial View Code:

Expanded Related Documentation

Expanded Online Demos

Expanded Online Examples

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