RadTreeView doesn't retrievechecked nodes

2 posts, 0 answers
  1. Babak
    Babak avatar
    12 posts
    Member since:
    Jan 2012

    Posted 14 Jan 2014 Link to this post

    Hi , I'm using radtreeview width checkbox="true" style .
    in button click I want to retrievechecked Items .
    I try to do this is 2 ways, but both have zero item counts . please check my code
    <asp:Button ID="Save" runat="server" Font-Names="Tahoma" Text="Save" OnClick="Save_Click" CssClass="savebutton"></asp:Button>
                          <telerik:RadTreeView ID="RadTreeView1" runat="server" DataTextField="SecNameFr" DataValueField="AccessId" DataFieldID="SecId" CheckBoxes="true" DataFieldParentID="SecIdRef" CheckChildNodes="true" Font-Names="tahoma" RenderMode="Classic" Skin="Office2010Blue">
                                  <telerik:RadTreeNodeBinding Checkable="true" CheckedField="HasAccess" />
    protected void Save_Click(object sender, EventArgs e)
               List<RadTreeNode> dss = RadTreeView1.CheckedNodes.ToList();
               Dictionary<int, bool> accessIdDic = new Dictionary<int, bool>();
               foreach (RadTreeNode item in RadTreeView1.Nodes)
                   if (item.Checked)
                       accessIdDic.Add(Convert.ToInt32(item.Value), item.Checked);
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Jan 2014 Link to this post


    Please have a look into the following code snippet which works fine at my end.

    <telerik:RadTreeView ID="RadTreeView1" runat="server" DataTextField="text" DataValueField="text"
        DataFieldID="id" CheckBoxes="true" DataFieldParentID="parentid" CheckChildNodes="true"
        Font-Names="tahoma" RenderMode="Classic" Skin="Office2010Blue" DataSourceID="SqlDataSource1">
            <telerik:RadTreeNodeBinding Checkable="true" CheckedField="status" />
    <telerik:RadButton ID="RadButton1" runat="server" Text="Save" OnClick="RadButton1_Click">

    protected void RadButton1_Click(object sender, EventArgs e)
        string[] array = new string[50];
        int i = 0;
        foreach (RadTreeNode item in RadTreeView1.CheckedNodes)
            array[i] = item.Text;

Back to Top