[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


SelectedNode of TreeView is not highlighted after selection

Posted on 2007-07-21
Medium Priority
Last Modified: 2012-08-13

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?

Question by:Relegence
  • 3
  • 2
LVL 16

Expert Comment

ID: 19540374
Are you adding the treeview to the page dynamically or is it created declaratively in the .aspx?

Author Comment

ID: 19541609
It is added dynamically
LVL 13

Assisted Solution

hiteshgoldeneye earned 400 total points
ID: 19542617
you can store the selected item in a variable and after postback assign treeview's selected item to this variable
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 16

Expert Comment

ID: 19542626
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.

Author Comment

ID: 19543346
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'
LVL 16

Accepted Solution

TSmooth earned 1600 total points
ID: 19543897
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.

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question