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:
uwtReportFolders.Nodes.Clear()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim items() As CatalogItem = Nothing
root.Text = "Root"
uwtReportFolders.Nodes.Add(root)
' Retrieve a list items from the server
Try
Dim j As Integer = 1
' Iterate through the list of items and find all of the folders and display them to the user
If ci.Type = ItemTypeEnum.Folder AndAlso (Not ci.Hidden) Then
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
End If
uwtReportFolders.SelectedNode.Nodes.Add(newNode) 'cannot figure this out
uwtReportFolders.Nodes.Add(newNode)
'addNode(ci.Name)
Next
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...
Hello,
Well, it is a bit hard to me to tell if this is the most efficient way since I do not know the whole scenario, but from the code snippet I see, this seems quite efficient (get all report items and create the respective nodes for them). I do not really think it can be faster / more efficient from that.
Thanks for sharing your solution in forums btw, integrating UltraWebTree with Reporting Services surely sounds like a great scenario and I am sure many people will find it useful.
Thanks for the information....
This is what I came up with and it works. Can you let me know if this is the most efficient way to do this?
If Not IsPostBack Then
root.Text = "Forms"
uwtReportFolders.SelectedNode = root
newNode = Nothing
currentNode = Nothing
currentNode = newNode
uwtReportFolders.SelectedNode = newNode
uwtReportFolders.SelectedNode.Nodes.Add(newNode)
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;