Skip to main content

TreeViewNode.TextTemplate Property

Gets or sets a template used for displaying the text content of the particular node.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.1.dll

NuGet Package: DevExpress.Web


public virtual ITemplate TextTemplate { get; set; }

Property Value

Type Default Description
ITemplate null

An object supporting the ITemplate interface which contains the template used for displaying the node’s text content.


Use the TextTemplate property to control the text content of the particular node. The template defined using this property replaces the text content of an individual node - in particular, the node’s text specified.

Note that any style settings defined for the node via specific properties (such as the TreeViewStyles.Node) are still in effect for the node whose content is specified through using the TextTemplate property.

In order to define a common text content for all nodes within an ASPxTreeView control, the ASPxTreeView.NodeTextTemplate property can be used.


Once a template defined by this property is created, it is instantiated within a container represented by the TreeViewNodeTemplateContainer class. The TreeViewNodeTemplateContainer class implements a set of properties which can be useful when designing a template and binding the controls composing this template to data.


This example illustrates how to create a template and assign it to TreeViewNode at runtime conditionally. As ASPxTreeView is bound to a datasource in this example, it is necessary to handle the ASPxTreeView.DataBound event to refer to a node.

View Example

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTreeView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>How to create TreeViewNode.TextTemplate at runtime</title>
    <form id="form1" runat="server">
        <dx:ASPxTreeView ID="treeView" runat="server" DataSourceID="XmlDataSource1" AllowSelectNode="true"
            OnNodeDataBound="treeView_NodeDataBound" TextField="Title" 
                <NodeImage Width="16px" Height="16px">
                <NodeImage Paddings-PaddingTop="3px">
        <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/HelpNav.xml"
See Also