Welcome Guest Search | Active Topics | Sign In | Register

TreeView: Retain what nodes are open Options
LNS Joe
Posted: Thursday, February 5, 2009 1:52:45 PM
Rank: Newbie
Groups: Member

Joined: 2/5/2009
Posts: 4
Is there a property im missing cause i cant seem to figure out how to get the TreeView to remember what i had opened when i click a node.

I'm hoping theres a simple fix, that wont involve too much javascript. but the only other way i see to do it is to make a routine that once fired saves all the states of the treeview's children and then reopens them on postback.
eo_support
Posted: Thursday, February 5, 2009 2:06:51 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,101
Hi,

The TreeView should automatically retain all its states information for you within the same page (for example, when the same page posts back). If your TreeView spans multiple pages (a typical scenario is when your TreeView is in your master page), you can set the TreeView's SaveStateCrossPages to true so that it will save state information for you when you navigate from one page to another.

A very common error that can cause the TreeView to lose state information is to repopulate the TreeView every time inside Page_Load. For example, if you populate the TreeView with the following code in your Page_Load every time:

Code: C#
TreeView1.DataSource = your_data_source;
TreeView1.DataBind();


This will cause the TreeView to lose all state information because the whole tree is rebuilt from your data source again. One way to correct this situation is to check whether the page is being posted back and skip binding if it is post back:

Code: C#
if (!Page.IsPostBack)
{
    TreeView1.DataSource = your_data_source;
    TreeView1.DataBind();
}


Hope this helps.

Thanks!
LNS Joe
Posted: Thursday, February 5, 2009 2:23:25 PM
Rank: Newbie
Groups: Member

Joined: 2/5/2009
Posts: 4
hi thank you for your response.

i thought i searched thru all properties, figures i missed "SaveStateCrossPages". that did the trick. thanks a bunch.
eo_support
Posted: Thursday, February 5, 2009 2:26:38 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,101
Cool. Glad it worked for you. Hope you like our product!
LNS Joe
Posted: Monday, February 16, 2009 10:32:12 AM
Rank: Newbie
Groups: Member

Joined: 2/5/2009
Posts: 4
ok now i've found a new issue, if i use a treeview navigation and a Menu, when you click the Menu it forgets the state of the treeview nav when it comes back to the page. any suggestions?
eo_support
Posted: Monday, February 16, 2009 11:17:38 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,101
Hi,

Try to set the TreeView's StateCookieName. That should save the state information into cookies and it should not interfere with anybody else.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.