Skip to main content
A newer version of this page is available. .
Tab

TreeViewNode.DataItem Property

Gets the data item that is bound to the node.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

public object DataItem { get; set; }

Property Value

Type Description
Object

A Object that represents the data item that is bound to the node.

Remarks

When the menu control is bound to a data source, such as a XmlDataSource object, this property is set to the data item that is bound to this specific node. This property is usually used to access the value of the data item.

Note

This property is available only after data binding has occurred.

Example

In this code, the ASPxTreeView is bound to an XML file using a standard XmlDataSource component. The ASPxTreeView’s TextField, ImageUrlField, and NavigateUrlField properties are used to specify the names of data item attributes from which the corresponding node settings should be obtained. The NodeDataBound event is handled to change the text style of nodes which represent classes (their text is displayed in bold).

using DevExpress.Web.ASPxTreeView;
using System.Xml;

public partial class TreeView_DataBinding : Page {
    protected void Page_Load(object sender, EventArgs e) {
        if (!IsPostBack) {
            treeView.DataBind();
            treeView.ExpandToDepth(0);
        }
    }

    protected void treeView_NodeDataBound(object source, TreeViewNodeEventArgs e) {
        XmlNode dataNode = ((e.Node.DataItem as IHierarchyData).Item as XmlNode);
        if (dataNode.Name == "class")
            e.Node.TextStyle.Font.Bold = true;
    }
}
See Also