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

[Solved] Unchecking Parent Node Unchecks All Child Nodes On Postback

3 Answers 220 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Raj Chaudhari
Top achievements
Rank 1
Raj Chaudhari asked on 17 Apr 2008, 11:33 AM
Hi,

Please help me with the following issue:

I construct my entire treeview dynamically using code. However when I uncheck a parent node and click a button to cause a postback, all child nodes of that parent also get unchecked. I want to avoid this behaviour. Please let me know how to fix this.

Also, please note that I am taking care of only constructing my treeview when Page.IsPostBack = false. Also the EnableViewState property of my treeview is set to true.

Thanks,
Raj

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 18 Apr 2008, 11:18 AM
Hi Raj Chaudhari,

I tried to reproduce the problem on my side but to no avail. Please find attached my test page. Let me know if I am missing something.

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Raj Chaudhari
Top achievements
Rank 1
answered on 21 Apr 2008, 10:10 AM
Hi Albert,

Since I could not find a way to attach my source code, please find the same below to replicate the problem. Note that Im using the following assembly version:

Setup File Name: RadControls_Prometheus_2007_3_1218_trial.exe
Assembly Name: Telerik.Web.UI
Version: 2007.3.1218.35

Im using VS 2008 RTM for my project.

Here is my Default.aspx source:

    <form id="form1" runat="server">  
        <asp:ScriptManager ID="sm" runat="server" /> 
        <telerik:RadTreeView ID="tv" CheckBoxes="true" runat="server" /> 
        <br /> 
        <asp:Button ID="btnPostBack" Text="Post Back" runat="server" /> 
    </form> 

Here is my Default.aspx.cs source:

    protected void Page_Load(object sender, EventArgs e)  
    {  
          
        if (this.IsPostBack == false)  
        {  
              
            Telerik.Web.UI.RadTreeNode root = new Telerik.Web.UI.RadTreeNode("Root");  
            root.Checkable = true;  
            root.Checked = true;  
            tv.Nodes.Add(root);  
              
            Telerik.Web.UI.RadTreeNode parent = new Telerik.Web.UI.RadTreeNode("Parent");  
            parent.Checkable = true;  
            parent.Checked = true;  
            root.Nodes.Add(parent);  
 
            Telerik.Web.UI.RadTreeNode child = new Telerik.Web.UI.RadTreeNode("Child");  
            child.Checkable = true;  
            child.Checked = true;  
            parent.Nodes.Add(child);  
 
            tv.ExpandAllNodes();  
 
        }  
 
    } 

Once you build and run this project and browse the Default.aspx page, uncheck the Root node and click Post Back button, you should see that parent and child nodes both get unchecked.

If you uncheck the Parent node and click Post Back button, you should see that child node gets unchecked.

In short - either this is a bug or its a feature - whenever I uncheck a parent node on cliend side and a Post Back happens, all the child nodes get unchecked too. If this is a bug, please provide me with a fix for the same. If this is a feature, please let me know how to disable this feature.

Thanks,
Raj
0
Nikolay
Telerik team
answered on 21 Apr 2008, 12:43 PM
Hello Raj Chaudhari,

I prepared another sample for you. Attached, please find the files. Download them and give them a go. I used the latest Telerik.Web.UI official version. Everything ran as expected at our side. Please try the attached sample at your end and let me know if the problem appears. If so, can you send the steps to reproduce it.

Thanks for your time.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
Raj Chaudhari
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Raj Chaudhari
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or