SelectedNode of TreeView is not highlighted after selection

Hello,

I am developing an asp.net 2.0 c# application.
I am using a treeView.
After selecting a node the page postsback and the node I selected is not highlighted.
How can I keep it highlighted after the postback?

Thanks
RelegenceAsked:
Who is Participating?
 
TSmoothConnect With a Mentor Commented:
You generally have to do it when you populate the treeview dynamically. In other words, as you are building the treeview by adding nodes to it, check the value of each node with your saved session value and if they match, set the node's selected property to true.
0
 
TSmoothCommented:
Are you adding the treeview to the page dynamically or is it created declaratively in the .aspx?
0
 
RelegenceAuthor Commented:
It is added dynamically
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Hitesh ManglaniConnect With a Mentor Commented:
you can store the selected item in a variable and after postback assign treeview's selected item to this variable
0
 
TSmoothCommented:
Since the treeview is added dynamically, it is re-created on every single post back and thus loses all of it's state information. You needed to store this information between post backs which can be done using a hidden form field, viewstate, or the session.
0
 
RelegenceAuthor Commented:
Can you please give an example of setting the selectedNode of a treeView, after I have saved the selectedNode in a session variable.
As far as I can see, the "SelectedNode" property is only for 'get' and not for 'set'
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.