Skip to main content
Tab

TreeViewNode.DataItem Property

Gets the data item that is bound to the node.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

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 TreeView 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