Hi all,

I'm trying to populate a treeview control in my asp.net environment from reports in sql server reporting services.

I almost have it done... With the code I am using I am getting it to populate, but every node is at top level, I can't get it to add the child nodes.

What could be wrong?

This is my code thusfar:

VB Code:
  1. Protected Sub LoadTree(ByVal items As NetcashReportService.CatalogItem())
  2.         rs.Credentials = nc
  3.         TreeReports.Nodes.Clear()
  4.         For Each item As NetcashReportService.CatalogItem In items
  5.             Dim parts As String() = item.Path.Split("/".ToCharArray)
  6.             Dim path As String = ""
  7.             Dim lastNode As TreeNode = Nothing
  8.             Dim lastPart As String = ""
  9.  
  10.             For Each t As String In parts
  11.                 lastPart = t
  12.                 If Not (path = "") Then
  13.                     path += "/"
  14.                 End If
  15.                 path += t
  16.                 Dim tn As TreeNode = TreeReports.FindNode(path)
  17.                 lastNode = tn
  18.             Next
  19.  
  20.             Dim newNode As TreeNode = New TreeNode(lastPart)
  21.             If lastNode Is Nothing Then
  22.                 TreeReports.Nodes.Add(newNode)
  23.             Else
  24.                 lastNode.ChildNodes.Add(newNode)
  25.             End If
  26.  
  27.         Next
  28.         SetTreeLinks(TreeReports.Nodes)
  29.         'TreeReports.ExpandDepth = 1
  30.     End Sub