Hi
I have a WebDataTree1, I want to expand a particular node with code. But the RootItem can not be fired.How can I fixed. thx.
protected void Button1_Click1(object sender, EventArgs e) { NavItem FindItem = WebDataTree1.Nodes.FindNavItemByText(TextBox1.Text, true); if (FindItem != null) { // WebDataTree1.Nodes[0].ExpandChildren(); // I must add this line at first before function(ExpandChildren) ExpandChildren((HierarchicalUIObject)FindItem); } }
private void ExpandChildren(HierarchicalUIObject item) { if (item.ParentItem != null && item.Level >= 0) { HierarchicalUIObject ChildrenObject = (HierarchicalUIObject)item.ParentItem; if (item.Level != 0) ((DataTreeNode)ChildrenObject).Nodes[item.Index].ExpandChildren(); else WebDataTree1.Nodes[item.Index].ExpandChildren();
ExpandChildren(ChildrenObject); } }
Hi Su Min,
What do you mean by 'RootItem can not be fired'? I created a small sample using your code and it worked as expected. I am attaching this sample for your reference.
Let me know if you have any questions.
Hello,
If you still need assistance with the matter, please let me know.