Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ''' <summary>
- ''' Fill treeMap Dictionary with collection of TreeNodes.
- ''' </summary>
- ''' <param name="treeMap"></param>
- ''' <remarks></remarks>
- Public Shared Sub BuildTree(ByRef treeMap As Dictionary(Of String, TreeNode))
- ' Build Tree Menu
- Dim ds As DataSet = GetMenuItems()
- Dim rootNode As New TreeNode("Manufacturing Documentation", "11")
- '' Root document has ID 11 in the DB.
- rootNode.ImageUrl = "images/folder.png"
- rootNode.NavigateUrl = "Document.aspx?doc=11&parent=0"
- treeMap("11") = rootNode
- For Each row As DataRow In ds.Tables(0).Rows
- Dim nodeId As String = row("nodeId")
- Dim parentId As String = row("parentId")
- Dim title As String = row("title")
- Dim _desc As Object = row("description")
- Dim desc As String = ""
- If Not _desc Is Nothing Then
- desc = _desc.ToString()
- End If
- If treeMap.ContainsKey(nodeId) Then
- treeMap(nodeId).Text = title
- treeMap(nodeId).Value = nodeId
- treeMap(nodeId).NavigateUrl = _
- String.Format("Document.aspx?doc={0}&parent={1}", nodeId, parentId)
- Else
- treeMap(nodeId) = New TreeNode(title, nodeId)
- treeMap(nodeId).Expanded = False
- treeMap(nodeId).NavigateUrl = _
- String.Format("Document.aspx?doc={0}&parent={1}", nodeId, parentId)
- If desc = "folder" Then
- treeMap(nodeId).ImageUrl = "images/folder.png"
- End If
- End If
- If Not treeMap.ContainsKey(parentId) Then
- treeMap(parentId) = New TreeNode()
- treeMap(parentId).Expanded = False
- End If
- treeMap(parentId).ChildNodes.Add(treeMap(nodeId))
- Next
- ' Set the NavigateUrl for each parent node (folder) to the first child document. This
- ' will open the folder and avoid dead pages (links to non-document objects).
- 'For Each node As String In treeMap.Keys
- ' If treeMap(node).ChildNodes.Count > 0 Then
- ' treeMap(node).NavigateUrl = String.Format("Document.aspx?doc={0}&parent={1}", treeMap(node).ChildNodes(0).Value, node)
- ' End If
- 'Next
- ds.Dispose()
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement