Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically Load TreeView

Status
Not open for further replies.

RobHudson

Programmer
Apr 30, 2001
172
GB
Have any of you guys used the TreeView control supplied by Microsoft??

I am dabbling in using it and my plan is to have it work in a similar fashion to that used on the MSDN pages.

The data for the tree will be coming from SQL Server, but because of a potentially large amount of data I only want to load the child data when the node is expanded.

I have managed to do quite a bit using the selectednodeindex, but that's no good if the node being expanded is not the selected node...

Any ideas on how to use the expand event and getting the expaned node etc. would really be good - thanks ;)
Rob
 
Hey Rob,

the onExpands server event is probably what you're looking for. All you'd have to do is get the node (which the onExpands gives you access to) that was selected to be expanded, get all the children from the SQL Server database, recreate the xml document, and then bind it to the treeview.

You could also look at just adding hte nodes if you aren't binding with xml (thats how we're doing it, but the documentation suggests there are other ways of manually adding nodes).

You probably already have this link, but in case you don't, this is MSDN's page about the Treeview:


let me know how it goes

D'Arcy
 
Hey!

I've done some hunting and have come up with this...

Public Sub treeExpanded(ByVal oSender As Object, ByVal oEvent As Microsoft.Web.UI.WebControls.TreeViewClickEventArgs) Handles trvSamples.Expand

Is that the correct syntax for the expand event? It does get fired which is a start! :)
Also, assuming this is correct how do I get the expanded node? The selected node appears to still be the first top level node in the tree...

Thanks
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top