This is a migrated thread and some comments may be shown as answers.

How to save only childnode.

1 Answer 32 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tuong Lan (FIS Soft)
Top achievements
Rank 1
Tuong Lan (FIS Soft) asked on 25 Apr 2011, 10:42 AM
I have a treeview (see attach file )
I want to save four nodes like circle.
I only save success node: Community. I cann't save three nodes: Development, Product, Operation.
Here is code to save:
List<RadTreeNode> checkedNodes = this.trvHierarchy.CheckedNodes.ToList<RadTreeNode>();
                 
List<string> lstJobNode = new List<string>();
 foreach (RadTreeNode node in checkedNodes)
 {
       if (string.IsNullOrEmpty(node.Value) == false
       && node.CheckState == TreeNodeCheckState.Checked)
        {
                 RadTreeNode parentNode = node.ParentNode;
//Only save parent. Don not save child if parent is checked.
                 if (parentNode == null || parentNode.CheckState != TreeNodeCheckState.Checked)
                                lstJobNode.Add(node.Value);
        }
}

1 Answer, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 28 Apr 2011, 12:16 PM
Hi Tuong Lan (FIS Soft),

Please make sure that the logic in the code behind that you have pasted is what you need to achieve. As I see, you intend to save only parent nodes whose checkboxes are checked.
if (string.IsNullOrEmpty(node.Value) == false
       && node.CheckState == TreeNodeCheckState.Checked)

However, in the screenshot that you attached, the items that you intended to save are not checked, therefore you are not able to save them. Try to check them (the parent nodes) and see if this works. 

Kind regards,
Kate
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
TreeView
Asked by
Tuong Lan (FIS Soft)
Top achievements
Rank 1
Answers by
Kate
Telerik team
Share this question
or