Free Trial Buy Now

Menu - Data Binding

Group A>
Group B>
Group C>
Group D>
Group E>
Group F>
Group G>
Group H>

Description

This demo illustrates how the ASPxMenu control can be populated with item information taken from a data source.

ASPxMenu supports binding to data sources, which can be any object that implements the IHierarchicalEnumerable or IHierarchicalDataSource interface (e.g. SiteMapDataSource, XmlDataSource, etc.). The ASPxMenu can be bound to a data source in the standard manner - using the DataSourceID or DataSource property.

While binding, the ASPxMenu control automatically creates the MenuItem objects and retrieves their property values from the corresponding items. The menu supports two methods of retrieving data from a specified data source. One involves manually setting the control's specific data-related properties (TextField, ImageUrlField, NavigateUrlField, NameField, and ToolTipField) to the data source item attribute names. The other one exploits ASPxMenu's ability to recognize data items and automatically retrieve some item characteristics from the data fields named in a specific way.

Additionally, ASPxMenu provides specific events related to data binding that you can handle according to your application logic.

  • The ItemDataBound event allows you to customize settings of an individual item immediately after it has been bound to data.
  • The DataBound event (which occurs after the control data binding has been finished) allows you to finally customize the control.

In this demo, the ASPxMenu control is bound to an ASPxSiteMapDataSource control by specifying just one DataSourceID property. An item's Text and NavigateUrl property values are automatically retrieved from the title and url SiteMapNode attributes. The ItemDataBound event is handled for two purposes: to add an image sprite CSS class to items that have the "SpriteImage" attribute within the data source; and to bold a score and add it to the text of items that have the "result" attribute within the data source.

Version: v2012 vol 2.8
Experience the DevExpress Difference Today
Demos with source code are included with an installation of DevExpress controls for ASP.NET. Refer to the Demos and Sample Applications topic to learn more.
To download your free evaluation copy of our award-winning ASP.NET libraries, visit the Downloads page
All DevExpress ASP.NET Controls ship as part of DXperience ASP.NET, Enterprise, and Universal.
To obtain pricing information, visit the Pricing Options page or contact us via Email at info@devexpress.com
or by telephone at +1 (818) 844-3383 between 8:30am and 5pm Pacific Time.