SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    May 2006
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getting all children from a tree node

    Hi all, im using the following code to check to see which tree nodes have been checked:

    Code:
    if (TreeView1.CheckedNodes.Count > 0)
            {
                // Iterate through the CheckedNodes collection and display the selected nodes.
                foreach (TreeNode node in TreeView1.CheckedNodes)
                {
                     if (node.Text == "Basic Details")
                    {
                        //CHECK ALL CHILD NODES                    
                    }
                }
            }
    If the "Basic Details" node has been checked, I would like to check to see if all the child nodes of the "Basic Details" node have been checked. However, i dont actually know the text property of the child nodes. is there any way of me checking all the child node of "Basic Details" without knowing their text value?

    Thanks

  2. #2
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can access the child nodes as a collection using the .ChildNodes property

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    You can check the controls with the help of childcontrols property

    if(TreeView1.CheckedNodes.Count >1)
    {
    foreach(TreeNode parentNode in TreeView1.CheckedNodes)
    {
    if(parentNode.Text.ToUpper() == "BASIC DETAILS")
    {
    foreach(TreeNode childNode in parentNode.ChildNodes)
    {
    if(childNode.Checked)
    {
    Response.Write(childNode.Text);
    }
    }
    }
    }
    }

    you can find the child controls in the above way.

    if anything you require then plz let me know.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •