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

DataItem in Databound Treeview

2 Answers 161 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Viktor Takacs
Top achievements
Rank 2
Viktor Takacs asked on 08 Jul 2011, 12:24 PM
Hi,
Is there a way to retrieve the dataitem of  the clicked node in a databound treeview? In the NodeClick event the e.Node.DataItem is null. I can only get the text.
Thanks for any ideas!
v

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Jul 2011, 08:59 AM
Hello Viktor,

The DataItem property is available only during databinding in the NodeDataBound event. You cannotnot use it elsewhere. You can use the Value property or Custom Attributes instead.

Thanks,
Shinu.
0
Viktor Takacs
Top achievements
Rank 2
answered on 11 Jul 2011, 11:09 AM
Hi Shinu,

Thanks for the reply. I see now that I can use a custom attribute to hold an id of some sort.

Thanks!
viktor
Tags
TreeView
Asked by
Viktor Takacs
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Viktor Takacs
Top achievements
Rank 2
Share this question
or