i have used below code for filtering tree view, it seems search function works correctly, but i do not know how to refresh tree view and populate that after clicking the button.
private IEnumerable<TreeNode> FindNodeByValue(TreeNodeCollection nodes, string searchstring)
{
foreach (TreeNode node in nodes)
{
if (node.Value.IndexOf(searchstring,
StringComparison.CurrentCultureIgnoreCase) >= 0)
yield return node;
else
{
foreach (var subNode in FindNodeByValue(node.ChildNodes, searchstring))
yield return subNode;
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
var query= FindNodeByValue(TreeView1.Nodes, fieldFilterTxtBx.Text);
if (query != null)
{
foreach (TreeNode node in query.ToList())
{
TreeView1.Nodes.Add(node);
}
TreeView1.ExpandAll();
}
else
{
Label1.Text = "No file found";
}
}