• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1225
  • Last Modified:

asp treeview checkboxlist

hey guys i have a treeview with checkboxlist. my problem is when i deselect a child node and if they if no other child node selected the parent node must be deselected.


i have code this so if the user select a parent all child be selected

here my code

    protected void TreeView_TreeNodeCheckChanged(object sender, TreeNodeEventArgs e)
    {
        if (e.Node.ChildNodes.Count > 0)
        {
            if (e.Node.Checked)
                ChangeChecked(e.Node, true);
            else
                ChangeChecked(e.Node, false);
        }
        else if (e.Node.Parent != null)
        {
            e.Node.Parent.Checked = true;
        }
    }

    private void ChangeChecked(TreeNode node, bool check)
    {
        if (node.ChildNodes.Count > 0)
        {
            for (int i = 0; i < node.ChildNodes.Count; i++)
                ChangeChecked(node.ChildNodes[i], check);
        }

        node.Checked = check;
    }

Open in new window

0
JCWEBHOST
Asked:
JCWEBHOST
1 Solution
 
Roopesh ReddyIT AnalystCommented:
Hi,

Check this ASP.NET Forum thread - http://forums.asp.net/t/1331963.aspx

It is solved using JavaScript!

Hope it helps u...
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now