Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[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
    Overview - GridView
    Main Features - GridView
   [Expand]Concepts
   [Expand]Visual Elements
   [Collapse]Examples
     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]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]HTML Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Navigation and Layout Extensions
  [Expand]File Management
  [Expand]Multi-Use Site Extensions
  [Expand]Charts
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Tree List
  [Expand]Data Editor Extensions
  [Expand]Report Extensions
  [Expand]SpellChecker
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Implement Custom Data Binding with Paging and Sorting

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4394.

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, please 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.

How would you rate this topic?​​​​​​​