Skip to main content
Tab

ASPxTreeView.NodeDataBound Event

Occurs after a node has been bound to a data source.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.2.dll

Declaration

public event TreeViewNodeEventHandler NodeDataBound

Event Data

The NodeDataBound event's data class is TreeViewNodeEventArgs. The following properties provide information specific to this event:

Property Description
Node Gets a node object related to the event.

Remarks

The NodeDataBound event is raised for each node after it’s data bound to the corresponding data from the specified data source. This event enables you to customize settings of the related node before it is finally rendered.

The processed node can be accessed by using the TreeViewNodeEventArgs.Node property of the event’s argument.

If the control functions in unbound mode, the NodeDataBound event isn’t raised.

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