Skip to main content

Automatic Data Binding

  • 2 minutes to read

ASPxMenu has a built-in ability to automatically retrieve data from a data source that supports the IHierarchicalEnumerable or IHierarchicalDataSource interface. This topic describes the conditions that allow the ASPxMenu control to bind to data after just one property (ASPxHierarchicalDataWebControl.DataSourceID or ASPxDataWebControlBase.DataSource) is specified.

ASPxMenu can recognize data items and retrieve some item characteristics from the data fields named in a specific way. If however, any of the data-related properties of an ASPxMenu control (such as ASPxMenuBase.TextField, ASPxMenuBase.ImageUrlField, etc.) have been set, then the mapping of the associated MenuItem object properties will proceed according to Data Binding Using Mapping Properties.

Data fields and item properties names match

During binding, ASPxMenu implements its automatic binding ability by retrieving item characteristics from those data fields whose names coincide with certain property names of a MenuItem object. The tables below list the names of the object properties that can be mapped during automatic binding, and the matching data field names you should use in the data source for mapping to work.

Data field names Item properties that can be set automatically
BeginGroup MenuItem.BeginGroup
Checked MenuItem.Checked
Enabled MenuItem.Enabled
GroupName MenuItem.GroupName
ImageUrl MenuItem.Image.Url
Name MenuItem.Name
NavigateUrl MenuItem.NavigateUrl
Selected MenuItem.Selected
Target MenuItem.Target
Text MenuItem.Text
ToolTip MenuItem.ToolTip
VisibleIndex MenuItem.VisibleIndex

The following image illustrates the process of data retrieval during automatic binding to a particular type of a data source - XmlDataSource.

ASPxMenu_BindAuto

Binding to a Site Map

Since the properties of a SiteMapNode object have specific names, ASPxMenu is designed to automatically bind to a Site Map source with node attributes of similar names. In the binding process, corresponding properties of individual MenuItem objects are automatically associated with these item attributes, and mapped accordingly. See the table below for name correspondence.

Site Map node attributes Corresponding Item object properties
Description MenuItem.ToolTip
Title MenuItem.Text
Url MenuItem.NavigateUrl

Note

The structure of a Site Map allows some flexibility in the naming of item attributes. After ASPxMenu detects the item attributes named title, url and description in the bound Site Map source, the conditions described in the above section apply.