How to expand specific Tree View Node programmatically in ASP.NET
How to expand specific Tree View Node programmatically in ASP.NET ?

In this case you can use
FindNode()
method to find a particular node and then use Expand()
method to expand that particular node. FindNode() take node name as
argument and return TreeNode if it’s found. You may even use ExpandAll()
method to expand all the subsequent child nodes.Expanding Specific Node using
Expand()
Method[sourcecode language="csharp"]
protected void buttonSearch_Click(object sender, EventArgs e)
{
aspTreeView.CollapseAll();
TreeNode searchNode = aspTreeView.FindNode(textSearch.Text);
if (searchNode != null)
searchNode.Expand();
}
[/sourcecode]

Expanding all subsequent Child Nodes using
ExpandAll()
Method[sourcecode language="csharp"]
protected void buttonSearch_Click(object sender, EventArgs e)
{
aspTreeView.CollapseAll();
TreeNode searchNode = aspTreeView.FindNode(textSearch.Text);
if (searchNode != null)
searchNode.ExpandAll();
}
[/sourcecode]

Sagar S Bhanushali
Comments
Post a Comment