This is a migrated thread and some comments may be shown as answers.

assign custom attributes to tree nodes

2 Answers 49 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
mirang
Top achievements
Rank 1
mirang asked on 07 Dec 2011, 05:41 PM
I am using datasource to bind the tree initially using DataBind() method. I am able to set Text, Image using RadTreeNodeBinding but not able to set custom attributes directly. Is there any way I can add the values to the node using datasource?

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Dec 2011, 05:22 AM
Hello Mirang,

Try the following code.
C#:
protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e)
{
  RadTreeNode child1 = new RadTreeNode("Child");
  child1.Attributes.Add("Text", "Value");
  RadTreeView1.Nodes.Add(child);
}
Also check the following help documentation.
Using Custom Attributes in Server-Side Code

-Shinu.
0
Bozhidar
Telerik team
answered on 08 Dec 2011, 10:02 AM
Hi Mirang,

Yes, you can bind additional attributes, using the NodeDataBound event. The method is explained here.

Greetings,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
TreeView
Asked by
mirang
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bozhidar
Telerik team
Share this question
or