Bind Menu to Data
ASPxMenu can be populated with item information taken from a data source, which can be any object that implements the IHierarchicalEnumerable or IHierarchicalDataSource interface (e.g. SiteMapDataSource, XmlDataSource, etc.).
A data source can be specified by using either one of the following properties of the ASPxMenu control:
- ASPxDataWebControlBase.DataSource to programmatically supply a data object.
- ASPxHierarchicalDataWebControl.DataSourceID to define a declarative data source.
The image below demonstrates the path for binding ASPxMenu to an XML file.
ASPxMenu supports two methods of retrieving data from a specified data source. One involves manually setting the control’s specific data-related properties to the data source item attribute names. The other one exploits ASPxMenu’s ability to retrieve data automatically, given that the data source item attributes are named after the property names of a MenuItem object.
Whichever way you choose, the ASPxMenu control automatically creates the MenuItem objects and retrieves their property values from the corresponding items.
Additionally, ASPxMenu provides you with specific events related to data binding that you can handle according to your application logic (for example, modify item content style).