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

Bind to textboxes based on selection of treeview nodes.

1 Answer 59 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Madhu Palakurthi
Top achievements
Rank 1
Madhu Palakurthi asked on 10 Dec 2012, 09:24 AM
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 ..

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 12 Dec 2012, 01:54 PM
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.
Tags
TreeView
Asked by
Madhu Palakurthi
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or