Binding to Data Overview
- 2 minutes to read
The ASPxTreeView can be populated with node information taken from a data source. Primarily designed to be a site navigation control, the ASPxTreeView supports binding to data sources containing hierarchical data. Any object that implements the IHierarchicalEnumerable or IHierarchicalDataSource interface (e.g. SiteMapDataSource, XmlDataSource, etc.) may be used as a data source for the ASPxTreeView control.
A data source can be specified by using either of following properties of the ASPxTreeView 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 an ASPxTreeView to an XML file.
The ASPxTreeView supports two methods to retrieve data from the 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 the ASPxTreeView's ability to retrieve data automatically, given that the data source item attributes are named after the property names of an ASPxTreeView object.
Whichever way you choose, the ASPxTreeView control automatically creates the TreeViewNode objects and retrieves their property values from the corresponding items.
Additionally, the ASPxTreeView provides you with specific events related to data binding that you can handle according to your application logic (for example, modify node content style).