Tab

ASPxTreeView.ImageUrlField Property

Gets or sets the name of a data field (or an xml element’s attribute) which provides URLs for images displayed within nodes.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v21.1.dll

Declaration

[DefaultValue("")]
public string ImageUrlField { 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 ImageUrlField property is in effect if the ASPxTreeView control is bound to a data source.

Use the ImageUrlField property to specify the bound data source’s data field (or an xml element’s attribute) which stores locations of images that should be displayed within nodes. The ImageUrlField property maps the Image.Url properties of the TreeViewNode objects to the specified data field’s values.

If the ImageUrlField property of a data bound ASPxTreeView control is not defined, the control can automatically obtain node image locations from a data field which is named “ImageUrl”.

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;
    }
}