Save treeview viewstate and reload it after the treeview is rebuilt

Hi Experts,

I use a treeview to display paths.
When user clicks a button, the treeview displays other paths from another datasource.
After that, the user can go back to the previous treeview, but if I reload it, the treeview is the same as first load : I mean the selected and expanded nodes are not the same as the user defined them previously.
That's why I want to know if it's possible to save the viewstate before the user changes my treeview and to reload this viewstate after I rebuilt the treeview.

Hope it's clear.
Thanks in advance for your answers.
LVL 9
nouloukAsked:
Who is Participating?
 
AerosSagaConnect With a Mentor Commented:
try this:

Protected Overrides Function SaveViewState() As Object

Viewstate("TreeView1") = Me.TreeView1

Return MyBase.SaveViewState()

0
 
jnhorstConnect With a Mentor Commented:
If you are using a button to send a postback that goes from one tree display to another, and you want to go back to the previous display, in that button's click event, save info about the selected node in the button's CommandArgument property.  When you reload the tree, you can use that info to select the node.  The info should be accessible in

Request.Form("__EVENTARGUMENT")

John
0
 
nouloukAuthor Commented:
I choose a different way to do what I want, but I think your answers are both available.
Thank you for your help.
0
 
AerosSagaCommented:
your very welcome
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.