Hi,
I have a treeview in my masterpage. When a contentpage is loaded i want to save the treeview state (which nodes are collapsed/expanded). I store the nodes in an ArrayList. Code:
private void SaveTreeviewState(TreeNodeCollection nodes)
{
foreach (TreeNode t in nodes)
{
// Store expandable state in ArrayList (true or false)
//NodePaths.Add(t.Expanded);
NodePaths.Add(t);
// Check for childnods
if (t.ChildNodes.Count > 0)
// recall this method
SaveTreeviewState(t.ChildNodes);
}
}
This method is called by the unload event of the treeview object:
protected void tvManual_Unload(object sender, EventArgs e)
{
SaveTreeviewState(tvManual.Nodes);
// Clear session
Session["Treeview"] = null;
// Add arraylistm to session
Session["Treeview"] = NodePaths;
}
In the load event of the masterpage i check whether my Session is set. When the session is set i call the method which read the session.
The arraylist in the session contains all my nodes, so that's correct. However, all nodes have the property expended set to false. This isn't correct because i expanded mupliple nodes.
Hope you guys understand my problem and can help me out.
Thnx in advanced