How can i goto to child node in my treeview

Last post 06-17-2008 1:27 AM by Amanda Wang - MSFT. 2 replies.

Sort Posts:

  • How can i goto to child node in my treeview

    06-15-2008, 9:59 PM
    • Member
      3 point Member
    • gslakmal
    • Member since 06-06-2008, 1:33 AM
    • Posts 123

    I have treeview. And i used following code to go through tree node. But its only going through in parent nodes. Its not going child nodes. How can i change code to goto child nodes


               foreach (TreeNode item in trvCategory.Nodes )
               {
                   lblError.Text = lblError.Text + "-@" + item.Value.ToString();
                   if (CatList.Contains(int.Parse(item.Value.ToString())))
                   {
                       trvCategory.FindNode(item.Value).Checked = true;
                   }
                   else
                       trvCategory.FindNode(item.Value).Checked = false;

    krds

    lakmal

     

    http://www.odesk.com/users/ASP-NET-Web-application-Designer-DotNetNuke-Expert_~~4fc245f3b8e64e9b
  • Re: How can i goto to child node in my treeview

    06-16-2008, 1:39 AM
    • Participant
      1,810 point Participant
    • cninjas
    • Member since 05-29-2007, 7:29 AM
    • Posts 317

    hi

    chk this link..should solve you problem

    http://forums.asp.net/p/1157191/1903260.aspx

     

  • Re: How can i goto to child node in my treeview

    06-17-2008, 1:27 AM
    Answer

    Hi,

    You can try to use recursion method to go through the treenodes.

    for example:

    protected void checkTreeview(TreeNode node)
        {
            if (node.ChildNodes.Count != 0)
            {
                foreach (TreeNode tn in node.ChildNodes)
                {
                    if (tn.ChildNodes.Count == 0)
                    {
                        tn.Checked = true;
                    }
                    else
                    {
                        checkTreeview(tn);
                    }
                }
            }
        }

    Hope it helps.

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (3 items)