[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Collapse]Data and Image Navigation
   [Expand]Product Information
     ASPxDataView Overview
      Binding to Data
      Data Items
      Layout Modes
      Data Paging
    [Expand]Visual Elements
   [Expand]Image Gallery
   [Expand]Image Slider
   [Expand]Image Zoom
   [Expand]News Control
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [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

Binding to Data

The ASPxDataView control displays set of data items organized in different ways depending on the chosen layout mode. To populate the control with the data items, you can bind it to the data source using one of the following approaches.


If the ASPxDataWebControl.DataSourceID property value is specified, the ASPxDataWebControlBase.DataSource property must be left blank, and vice versa. These two properties should never be set at the same time.

Expanded Binding ASPxDataView to data declaratively

You can bind the ASPxDataView control to a data source control in markup. Set the ASPxDataWebControl.DataSourceID property value to the ID of the target data source control. When you assign a data source to the control at design time, a default item template for displaying data items is automatically created.

In the example below, the data view is bound to the XmlDataSource control. A custom item template is created in the markup to display XML data from the data source.

Show Me

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

Expanded Binding ASPxDataView to data programmatically

You can bind the ASPxDataView control to any object implementing the IEnumerable interface, such as: ADO.NET datasets, data readers (e.g., SqlDataReader, OleDbDataReader) and most collections.

To bind the data view to the custom data source object, assign it as the ASPxDataWebControlBase.DataSource property value and call the ASPxWebControl.DataBind method. In this case, an item template should be created manually. In the example below, the Enumerable.Range method is used to create a custom data source. The item template is created at runtime.

Show Me

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

Expanded ASPxDataView Events Related to Data Binding

  • When the ASPxDataView control is bound to the data source (either automatically if the ASPxDataWebControl.DataSourceID property is specified, or manually with the ASPxWebControl.DataBind method), the DataBinding is raised allowing you to perform any data-binding logic. For example, you can call the ASPxWebControl.DataBind method before assigning any data source to the data view and use the DataBinding event handler to provide data.

  • After the ASPxDataView control is bound to the data, the ASPxDataWebControlBase.DataBound is raised notifying the control that all data binding logic is completed. You can use the ASPxDataWebControlBase.DataBound event handler to perform any required operation based on the data bound to the control.

Expanded See Also

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