[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
    Main Features
   [Expand]Visual Elements
   [Expand]Member Tables
     How to: Implement Custom Data Binding with Paging and Sorting
     How to: Implement a Custom Binding Scenario for Two GridViews Used in a Master-Detail Relationship
  [Expand]Tree List
  [Expand]Card View
  [Expand]Pivot Grid
   Rich Text Editor
  [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]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]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Implement Custom Data Binding with Paging and Sorting

This sample demonstrates how to implement a simple custom binding scenario for the GridView extension by handling only sorting and paging operations in the corresponding Action methods.

To learn more on the GridView's custom data binding feature, refer to the Custom Data Binding - Overview help topic.

Note that this sample provides a universal implementation approach - it can be easily adopted and used for every custom data source object that implements the IQueryable interface.

In short, the logic of this custom binding implementation is as follows:

  • In the GridView's Partial View (Views > Home > GridViewPartial.cshtml), the grid's GridViewSettings.CustomBindingRouteValuesCollection property is used to define handling actions for sorting and paging operations; the GridSettingsBase.CallbackRouteValues property defines the action to handle all other (standard) grid callbacks.
  • In the Controller (Controller > HomeController.cs), the specified Action methods are implemented to update a specific grid view model object (GridViewModel that maintains the grid state) with information on the performed operation (if required). Then, the grid view model's GridViewModel.ProcessCustomBinding method is called to delegate a binding implementation to specific model-layer methods pointed by the method's certain parameters.
  • At the Model layer (Models > CustomBindingModel.cs), the two specified delegates are implemented to populate the grid view mode with the required data. Generally, in the provided model-level implementation, you just need to modify a single code line to point to your particular model object that implements the IQueryable interface:

  • Finally, the resulting grid view model object is passed from the Controller to the grid's Partial View as a Model. In the Partial View, the grid is bound to the Model via the GridViewExtension.BindToCustomData method.

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