treeview control

Prawwo_ue557

New Member
has anybody messed with the treeview control? how do i add nodes dynamically? and does anyone know how to dynamically make an XML file with a SQL stored procedure, and call it with the treeview?Hi<BR><BR>I have done quite a bit of playing with the treeview control. I have been using VB.NET to extract records from a database and dynamically add them to a tree view - below is a snapshot of a bit of my code:<BR><BR>Private Sub CreateRootNode()<BR> Dim oTree As Microsoft.Web.UI.WebControls.TreeView = TreeView1<BR> Dim newRootNode As VBSNode = WebForm1.myVBSDI.getRootNodeForView(TreeViewID, WebForm1.SessionID)<BR> Dim RootNode As New Microsoft.Web.UI.WebControls.TreeNode()<BR> RootNode.Text = newRootNode.stat & vbTab & newRootNode.label<BR> RootNode.ID = newRootNode.ID<BR> RootNode.Expanded = True<BR> AddChildNodesToNode(RootNode, 0)<BR> oTree.Nodes.Add(RootNode)<BR> End Sub<BR><BR> Private Sub AddChildNodesToNode(ByVal strNode As Microsoft.Web.UI.WebControls.TreeNode, ByVal depth As Integer)<BR> If WebForm1.myVBSDI.CheckForChildren(strNode.ID, 0, WebForm1.SessionID) > 0 Then<BR> Dim childDepth = depth + 1<BR> Dim mask As Integer = Len(strNode.ID)<BR> Dim childNodeArray As New ArrayList(WebForm1.myVBSDI.getChildNodes(mask, childDepth, strNode.ID, WebForm1.SessionID))<BR> Dim i As Integer<BR> For i = 0 To childNodeArray.Count - 1<BR> Dim vtb As New Microsoft.Web.UI.WebControls.TreeNode()<BR> Dim myNode As VBSNode = childNodeArray(i)<BR> vtb.ID = myNode.ID<BR> vtb.Text = myNode.stat & vbTab & myNode.label<BR> If myNode.nodeType <> "Data" Then<BR> vtb.Expandable = Microsoft.Web.UI.WebControls.ExpandableValue.Alway s<BR> End If<BR> strNode.Nodes.Add(vtb)<BR> AddChildNodesToNode(vtb, childDepth)<BR> Next<BR> End If<BR> End Sub<BR><BR>I know the code is a little specific but if you do a search on google for asp.net treeview dynamic xml - there will be several tutorial pages about it. By the way msdn is useful in their basic tutorials but after that it is pretty awful.<BR><BR>Good Luck<BR><BR>Feel free to reply to this post if you want me to elaborate.<BR><BR>p.s. here is a cracking link for dynamic treeview stuff:<BR><BR>http://www.flws.com.au/showusyourcode/codeLib/code/NET_TreeView.asp?catID=5<BR>i was trying to avoid using the treenodes collection for performance reasons. have you tried using an xml document at all?thanks a ton, you pointed me in the right direction
 
Back
Top