Reputation: 10164
i have a databound treeview in asp.net. how can i expand the root node and have the rest of the tree nodes all colapsed?
thanks
Upvotes: 1
Views: 3429
Reputation: 3552
To expand a parent at a time on click event, you can try the following code:
protected void tvMenu_SelectedNodeChanged(object sender, EventArgs e)
{
TreeNode tn = tvMenu.SelectedNode;
tn.ExpandAll();
}
Upvotes: 0
Reputation: 26190
Well, for the root node of the tree, you would do it like this:
TreeView1.CollapseAll();
TreeView1.Nodes[0].Expand();
Upvotes: 2