I used a code like this to load my data:
But I need expland all my nodes when I load the page. How can I expland all nodes without use the event
Thanks.
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
LoadRootNodes()
End If
End Sub
Private Sub LoadRootNodes()
Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("TelerikConnectionString").ConnectionString)
Dim selectCommand As New SqlCommand("SELECT * FROM Nodes WHERE ParentId IS NULL", connection)
Dim adapter As New SqlDataAdapter(selectCommand)
Dim data As New DataTable()
adapter.Fill(data)
For Each row As DataRow In data.Rows
Dim node As New RadTreeNode()
node.Text = row("Text")
node.Value = row("Id")
node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack
RadTreeView1.Nodes.Add(node)
Next
End Sub
Protected Sub RadTreeView1_NodeExpand(ByVal sender As Object, ByVal e As RadTreeNodeEventArgs) Handles RadTreeView1.NodeExpand
Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("TelerikConnectionString").ConnectionString)
Dim selectCommand As New SqlCommand("SELECT Nodes.Id AS NodeId, Nodes.Text AS NodeText, COUNT(Children.Id) AS ChildCount FROM Nodes LEFT JOIN Nodes As Children ON Nodes.Id = Children.ParentId WHERE Nodes.ParentId = @parentId GROUP BY Nodes.Id, Nodes.Text", connection)
selectCommand.Parameters.AddWithValue("parentId", e.Node.Value)
Dim adapter As New SqlDataAdapter(selectCommand)
Dim data As New DataTable()
adapter.Fill(data)
For Each row As DataRow In data.Rows
Dim node As New RadTreeNode()
node.Text = row("NodeText")
node.Value = row("NodeId")
If CInt(row("ChildCount")) > 0 Then
node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack
End If
e.Node.Nodes.Add(node)
Next
e.Node.Expanded = True
End Sub
But I need expland all my nodes when I load the page. How can I expland all nodes without use the event
RadTreeView1_NodeExpand
.Thanks.