Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
810
Can not Expand RootItem.ChildrenNode
posted

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);
  }
}

Parents
No Data
Reply Children