Hi,
Reza2011:
Let me explain more: i just want to expand or collapse nodes based on a drop down Selected index change. I thought the "Find Node" method for treeview and then "Expand" will do the job but it gives me errors.
You can use the find node method to find the node, the treenode's valuepath as the parameter. Like below code:
protected void lbClose_Click(object sender, EventArgs e)
{
TreeNode tn = this.TreeView1.FindNode("Home/School"); // the school treenode
if (tn.Expanded == true)
{
this.TreeView1.CollapseAll();
this.lbClose.Text = "open";
}
else
{
this.TreeView1.ExpandAll();
this.lbClose.Text = "Close";
}
}
Hope it helps.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Yours sincerely,
Amanda Wang
Microsoft Online Community Support