Bind to textboxes based on selection of treeview nodes.

2 posts, 0 answers
  1. Madhu Palakurthi
    Madhu Palakurthi avatar
    48 posts
    Member since:
    Nov 2009

    Posted 10 Dec 2012 Link to this post

    Hi,

    I calling this function from other page (gridview editclick event) .
     So then EditValue(refer code) has some value and binding in to treeview .

    Private Sub BindTreeView(ByVal dt As DataTable, ByVal EditValue As String, ByVal searchedColumn As String)
            Try
                Dim siteData As New List(Of TreeViewCheckbox)()
                If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
                    siteData.Add(New TreeViewCheckbox(1, 0, "Select All"))
     
                    Dim i As Integer = 0
                    Do While (i < dt.Rows.Count)
                        Dim row As DataRow = dt.Rows(i)
                        Dim srColumn As String = row(searchedColumn)
                        i = (i + 1)
                        siteData.Add(New TreeViewCheckbox(i + 1, 1, srColumn))
                    Loop
                End If
     
                If Not String.IsNullOrEmpty(EditValue) Then
                    siteData.Add(New TreeViewCheckbox(1, 0, "Select All"))
                    siteData.Add(New TreeViewCheckbox(2, 1, EditValue.Trim()))
                End If
     
                tvChkSearchResult.DataTextField = "Text"
                tvChkSearchResult.DataFieldID = "ID"
                tvChkSearchResult.DataFieldParentID = "ParentID"
                tvChkSearchResult.DataSource = siteData
                tvChkSearchResult.DataBind()
     
                If (siteData.Count = 0) Then
                    RadWindowManager1.RadAlert("No results found,Please try again.", 330, 100, Nothing, Nothing)
                Else
                    tvChkSearchResult.ExpandAllNodes()
                    HideControls(True)
                End If
            Catch ex As Exception
                RadWindowManager1.RadAlert(ex.Message, 330, 100, Nothing, Nothing)
            End Try
     
        End Sub

    Here adding in to siteData ...
    If Not String.IsNullOrEmpty(EditValue) Then
                    siteData.Add(New TreeViewCheckbox(1, 0, "Select All"))
                    siteData.Add(New TreeViewCheckbox(2, 1, EditValue.Trim()))
                End If

    Once datasource set by sitedata then I need to call event to fillup other 3 textboxes values that based on node value selected(edit value).

    How I can do fill up textboxes ? please help me on this.

    Thanks in advance ..
  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 12 Dec 2012 Link to this post

    Hello,

    I would recommend you to use the server-side NodeDataBound event handler. You can access the current node using the e.Node expression and use its properties.

    Protected Sub tvChkSearchResult_NodeDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles tvChkSearchResult.NodeDataBound
       // here goes your custom logic to modify your text boxes using the current node object
        End Sub

    Regards,
    Boyan Dimitrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top