Problem retrieving checked nodes on treeview

2 posts, 0 answers
  1. Pablo
    Pablo avatar
    2 posts
    Member since:
    May 2011

    Posted 01 Mar 2012 Link to this post


    I have a Treeview called RadTreeView1 which is already populated as follows, this is working perfect:

    Do While RS.Read
        If RS(0) = 1 Then
            Dim Node As New RadTreeNode
            Node.Text = (RS(2) & " " & RS(3) & " (" & RS(1) & ")")
            Node.Value = RS(1)
            Node.Checkable = True
            Dim foundNode As RadTreeNode = RadTreeView1.FindNodeByValue(RS(5))
            If foundNode IsNot Nothing Then
                Dim Node As New RadTreeNode
                Node.Text = (RS(2) & " " & RS(3) & " (" & RS(1) & ")")
                Node.Value = RS(1)
                Node.Checkable = False
            End If
        End If

    I've set the root values checkable=true and all the children as checkable=false (so the user can only check or uncheck the root values). Each node has a value which is an integer number.

    What I need to do is to click on a button, and retrieve all those nodes that are checked. Im using the code below but its not working:

    Imports Telerik.Web.UI
    Partial Class Hierarchy_Compression
        Inherits System.Web.UI.Page
        Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
            Dim Compression As IList(Of RadTreeNode) = RadTreeView1.CheckedNodes
            For Each node As RadTreeNode In Compression
                If node.Checked = True Then
                End If
        End Sub
    End Class

    What am I doing wrong?!

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Mar 2012 Link to this post


    Try the following code.
    protected void btnSubmit_Click(object sender, EventArgs e)
      IList<RadTreeNode> Compression = RadTreeView1.CheckedNodes;
       foreach (RadTreeNode node in Compression)

Back to Top