Setting Checked Nodes

2 posts, 0 answers
  1. James B.
    James B. avatar
    24 posts
    Member since:
    Jan 2011

    Posted 17 Jan 2011 Link to this post

    I'm trying to set checkboxes as checked on a radtreeview with tristatecheckboxes set to true. Using the code below works when there is only one level, but having trouble where there are 3 levels (passing in a comma delimted string of checkbox values).

    protected void selectCheckedNodes(RadTreeView treeView, string val)
            {
                if (!string.IsNullOrEmpty(val))
                {
                    string[] cbarray = new string[] { "" };
                    cbarray = val.Split(',');

                    foreach (string i in cbarray)
                    {
                        
                        RadTreeNode obj = treeView.Nodes.FindNodeByValue(i);
                        if (obj != null)
                            obj.Checked = true;
                    }
                }
            }

    Can someone show me how to iterate thru the treeview to check the approriate nodes? I am not passing in the parent categories, just the specific nodes I want checked. Thanks!
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Jan 2011 Link to this post

    Hello James,


    You could use the following code to access corresponding node at runtime.
                 RadTreeNode obj = treeView.FindNodeByValue(i);


    Another option is iterating through all the nodes in treeview and check for the Value to get the required.
    foreach (RadTreeNode node in RadTreeView1.GetAllNodes())
    {
        if (node.Value== "Car") // condition
        {
            node.Selected = true;
            break;
        }
    }



    -Shinu.
Back to Top