|
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.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
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!
|
|
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.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Cool. Glad it worked for you. Hope you like our product!
|
|
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?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
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!
|
|