Skip to main content
Tab

ASPxTreeView.TextField Property

Gets or sets the data source field that provides caption texts for nodes.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue("")]
public string TextField { get; set; }

Property Value

Type Default Description
String String.Empty

A string value that specifies the name of the required data source field.

Remarks

The TextField property is in effect if the ASPxTreeView control is bound to a data source.

Use the TextField property to specify the bound data source’s data field (or an xml element’s attribute) which stores node texts. The TextField property maps the TreeViewNode.Text properties of TreeViewNode objects to the specified data field’s values.

You can format the obtained texts by using the ASPxTreeView.TextFormatString property.

If the TextField property of a data bound ASPxTreeView control is not defined, the control can automatically obtain node texts from a data field whose name is “Text” (which is equal to the TreeViewNode.Text property’s name).

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