Hm, I seem to be getting some strange behaviour from the code above after all. This is my code, placed in the page_load method:
if(Request.QueryString[\"path\"] != null)
{
string PATH = Request.QueryString[\"path\"].ToString();
FlyTreeNodeCollection nodes = TreeView.Nodes;
FlyTreeNodeCollection sn;
string[] values = PATH.Split(';');
string lastNode = values[values.Length - 1];
foreach(string s in values)
{
sn = nodes.FindByValue(s, true);
foreach (FlyTreeNode ftn in sn)
{
ftn.Expanded = true;
TreeView.PopulateExpandedNodes();
nodes = ftn.ChildNodes;
if (String.Equals(s, lastNode))
{
ftn.Selected = true;
}
}
}
TreeView.FocusNode = TreeView.SelectedNode;
}
And everything seems to work fine when I navigate to a new page. The tree gets expanded correctly, the selected node gets selected AND focused.
However, everytime I make a postback in the new page, the tree seems to expand other nodes too. I checked the path to the \"extra\" nodes that get expanded, to the CORRECT node, and the path is different. I can't for the life of my understand why it does it. Can you see any error in my code above? Or is there some bug in the PopulateExpandedNodes() method perhaps?
Thankx.