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
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Scheduler
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Gauges
  [Expand]Vertical Grid
  [Collapse]Data Editors
   [Expand]Product Information
   [Collapse]Common Concepts
     Binding to Data
    [Expand]Mask Editing
    [Expand]Validation
    [Expand]List Editors
     Accessibility Support
   [Expand]Editor Types
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [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]Office File API
[Expand]Reporting
[Expand]Report and Dashboard 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

Data editors can be bound to data in the same manner as standard server controls. You can use standard data-binding expressions placed between <%# and %>. Almost any editor property can be bound against any public field or property on the page or on the editor's immediate naming container.

In data-binding expressions, use the Eval and Bind methods to bind data to editors and submit changes back to the database. The Eval method is a static (read-only) method that takes the value of a data field and returns it as a string. The Bind method supports read/write functionality with the ability to retrieve the values of data-bound editors and submit any changes made back to the database.

Note that editors containing item lists (such as the ASPxComboBox, ASPxListBox, ASPxRadioButtonList) can be bound to a data source and fetch list items dynamically. Item display settings (such as caption text, associated value, displayed image) are retrieved from the data source's fields specified via editor properties.

refer to our Editor Data Binding demo for editor data binding examples.

Expanded List Editors Data Binding

When you use binding expressions in a list editor (ASPxComboBox or ASPxListBox), which is placed within a bound control, then the editor's DataBind (ASPxComboBox.DataBind/ASPxWebControl.DataBind) method can cause the following exception: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. The exception occurs because the external control is not yet bound by this time and data expressions cannot be evaluated.

To prevent the exception, use the DataBindItems (ASPxAutoCompleteBoxBase.DataBindItems/ASPxListBox.DataBindItems) method instead. The method is similar to the DataBind method, but prevents the base.DataBind method call. As the result the data expressions are not evaluated and the exception is not thrown. Note that the DataBindingItems method does not raise the DataBinding event.

The problem described above can also appear when you bind a list editor within its Callback event handler (ASPxAutoCompleteBoxBase.Callback/ASPxListBox.Callback). To prevent the exception, a list editor ignores the DataBind method call within a Callback event handler, and calls the DataBindItems method instead. As a result, the DataBinding event is not raised.

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