RadTreeView for ASP.NET

DataBinding expressions Send comments on this topic.
Templates > DataBinding expressions

Glossary Item Box

How to populate controls that are inside treeview templates (Unbound Mode)

Consider the following scenario:

  1. Suppose you have a simple treeview and you build it with the designer like this:

  2. Add a global template with a button.
  3. Add a node template for child 1.1 with a label (for more information view the topic on How to add and edit templates Design Time).

If you run the application at this point the Telerik RadTreeView will display the items with the templated controls' settings:


However, you can override the templated controls properties using
<%# DataBinder.Eval(Container, "Item's Property Field") %>

For example, let's say we want to override the Text property of the templated controls with the Text Property of the tree nodes:

The effect of the above code  will be:

How to populate controls that are inside treeview templates (DataBound Mode)

When you are databinding the treeview to a datasource the only thing that is different from the unbound mode is the DataItem extension of the Container: <%# DataBinder.Eval(Container.DataItem, "Text") %>

For example:


Using the following datasource: