Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]Welcome to DevExpress .NET Documentation
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Collapse]Image and Data Browsing
   [Expand]Product Information
   [Collapse]DataView
     ASPxDataView Overview
    [Collapse]Concepts
      Binding to Data
      Data Items
      Layout Modes
      Data Paging
    [Expand]Visual Elements
   [Expand]Headline
   [Expand]Image Gallery
   [Expand]Image Slider
   [Expand]Image Zoom
   [Expand]News Control
   [Expand]Pager
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Expand]File Management
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Expand]HTML Editor
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [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]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[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.

Important

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?​​​​​​​