Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
264
Treeview from SQL Reporting Services..
posted

I am trying to build a tree view from Reporting Sevices (I have added a reference to my web app for Reporting service).

I have the following code:

Protected Sub uwtReportFolders_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles uwtReportFolders.LoadDim rs As ReportingService2005

uwtReportFolders.Nodes.Clear()

rs =
New ReportingService2005()

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim items() As CatalogItem = Nothing

Dim root As Node = New Node()

root.Text = "Root"

uwtReportFolders.Nodes.Add(root)

' Retrieve a list items from the server

Try

items = rs.ListChildren("/", True)

Dim j As Integer = 1

' Iterate through the list of items and find all of the folders and display them to the user

For Each ci In items

If ci.Type = ItemTypeEnum.Folder AndAlso (Not ci.Hidden) Then

Dim rx As Regex = New Regex("/")

Dim matchCnt As Integer = rx.Matches(ci.Path).Count

If matchCnt > j Then

uwtReportFolders.SelectedNode = 'cannot figure this out

j = matchCnt

ElseIf matchCnt < j Then

uwtReportFolders.SelectedNode = 'cannot figure this out

j = matchCnt

End If

Dim newNode As Node = New Node(ci.Name, "", "", "", "")

uwtReportFolders.SelectedNode.Nodes.Add(newNode) 'cannot figure this out

uwtReportFolders.Nodes.Add(newNode)

'addNode(ci.Name)

End If

Next

Catch ex As SoapException

Catch ex As Exception

End Try

End Sub

First of all.  I don't know if this is the best way to do this.  I am trying to avoid using the tables just is case the structure changes.

I cannot figure out how to set the selected node (again this may not be the best way to do it)  so that I can add the newest node to it.

Any suggestions??

Thanks...

Parents
  • 28464
    posted

    Hello,

    Yes, I think the approach you have chosen is good - go through the results of the reporting services query and add nodes to the treeview based on that. So this is good.

    As far as selected node goes, there are two approaches - first, when you create a new node, you can always set its Selected property to true  - from this point on it becomes the UltraWebTree.SelectedNode (if it is added to the tree). Or alternatively, you can create a new node and set the SelectedNode to the node of the property.

    e.g.

          // approach #1

            Node node = new Node();
            node.Selected = true;

       

          // approach #2
            Node node = new Node();

            UltraWebTree1.SelectedNode = node;

Reply Children