Automatic Data Binding
- 3 minutes to read
The ASPxTabControl has a unique built-in ability to automatically retrieve data from a data source that supports the IHierarchicalEnumerable or IHierarchicalDataSource interface. This topic describes the conditions that let ASPxTabControl bind to data after just one property (ASPxHierarchicalDataWebControl.DataSourceID or ASPxDataWebControlBase.DataSource) is specified.
Generally speaking, the ASPxTabControl possesses the ability to recognize the data items and retrieve some tab characteristics from the data fields named in a specific way. If however, any of the data-related properties of a Tab control have been set, then the mapping of the associated Tab object properties will proceed according to Data Binding Using Mapping Properties.
Data fields and Tab properties name match
During binding, Tab control implements its autobinding ability by retrieving tab characteristics from those data fields whose names coincide with certain property names of a Tab object. The table below lists the names of those Tab object properties that can be mapped during autobinding, and the matching data field names you should use in the data source for the mapping to work. Note that the match is not case-sensitive.
Tab properties that can be set automatically | Data field names |
---|---|
ActiveTabImage.Url | ActiveTabImageUrl |
TabBase.Name | Name |
Tab.NavigateUrl | NavigateUrl |
TabImage.Url | TabImageUrl |
TabBase.Text | Text |
TabBase.ToolTip | ToolTip |
Note
The names of data fields corresponding to the Tab properties of a complex structure are made up of two components: the property name and the subproperty name. Notice in the table above that the data field name TabImageUrl contains the TabImage property name and the Url subproperty name.
The following picture illustrates the process of data retrieval during automatic binding to a particular type of data source - XmlDataSource. The XmlDataSource properties are not shown here. Note that in this example the XmlDataSource is bound to the TabControlDataSource.xml file.
Note
The ASPxTabControl Tabs Editor window shown here will not be accessible in the autobinding mode. We used it here exclusively to demonstrate how the data fields should be named, so that the Tab object properties reflected their values.
Binding to a Site Map
Since the properties of a SiteMapNode object have specific names (Title, Url, Description) the ASPxTabControl is designed to autobind to a Site Map source with node attributes with similar names (not case-sensitive). In the process of binding, corresponding properties of individual Tab objects are automatically associated with these node attributes, and mapped accordingly. See the table below for name correspondence.
Site Map node attributes | Corresponding Tab object properties |
---|---|
title | Text |
url | NavigateUrl |
description | ToolTip |
Note
The structure of a Site Map allows flexibility in the naming of node attributes. If the APSxTabControl does not detect the node attributes named title, url and description in the bound Site Map source, the conditions described in the above section Data fields and Tab properties name match apply.
Tab control can bind to the Site Map via the SiteMapDataSource or the ASPxSiteMapDataSource control. The picture below demonstrates the process of data retrieval and Tab object property mapping, when binding via the ASPxSiteMapDataSource control.