[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
  [Collapse]Site Navigation and Layout
   [Expand]Product Information
   [Expand]Form Layout
     ASPxMenu Overview
     [Collapse]Binding to Data
       Binding to Data Overview
       Data Binding Using Mapping Properties
       Automatic Data Binding
       Using Data Binding Events
      [Expand]Unbound Mode
      Item Link Mode
    [Expand]Visual Elements
   [Expand]Navigation Bar
   [Expand]Page Control and Tab Control
    Panel Overview
   [Expand]Site Map Control
   [Expand]Tag Cloud Control
   [Expand]Title Index
  [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 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

Using Data Binding Events

The ASPxMenu control implements specific data-binding events - ASPxMenuBase.ItemDataBound and ASPxDataWebControlBase.DataBound. They allow you to perform custom operations at specific times in the data binding process.

The ItemDataBound event occurs immediately after an individual MenuItem object has been automatically created, and its properties have been initialized with values retrieved from corresponding data fields. You can add functionality to your application within a handler of the ItemDataBound event by accessing the data bound item via the event argument's MenuItemEventArgs.Item property, and modify its settings as required. Also, the MenuItem.DataItem property can be used to access the item's corresponding data item object and any data field value can be obtained.

The DataBound event is invoked to notify you that any data binding logic used by the ASPxMenu control has been completed. This event occurs after all data items of the specified data source have been processed and the corresponding MenuItem objects have been added. You can also implement additional logic at this moment by providing a handler to the DataBound event.

Expanded Example

In the code sample below, the ASPxMenu control is bound to a Site Map data source using the ASPxSiteMapDataSource component. An item's MenuItem.NavigateUrl and MenuItem.Text property values are automatically retrieved from the url and title Site Map node attributes respectively (to learn more, see the Automatic Data Binding topic). The ItemDataBound event is handled for two purposes.

  1. To add an image sprite CSS class to items that have the corresponding attribute ("SpriteImage") within the data source.
  2. To bold a score and add it to text of items that have the corresponding attribute ("result") within the data source.

The image below shows the result.

You can see the complete sample in the Menu - Data Binding on-line demo.

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