Oh, yeah, another question that asks me to dig through beaucoup code *BIG GRIN* On second thought, let's see if we can get that information without having to dig.
Are you binding the TreeView to an XmlDataSource?
Main Topics
Browse All TopicsI am trying to setup the TreeView control to show data from a table. I got it going more or less OK when it is based on a static XML file, but when I use data from database it shows me the root node (hard coded in the control) and instead of parent/leaf shows only leafs. I expect to have one node with parents and one with leafs (three with the root) and be able to click just as the XML version is working... I used sample from MSDN with almost no modifications, just adapted it to my data, apparently I do not see a significant difference...
can someone find why the data-driven control is not working properly? I post all necessary files (hopefully), you just need to load data into a database and change web.config to point to it.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
1) I need to bind tree view dynamically to the database. I did second tree bound to xml as I was learning as it is simpler and no code comparing to when binding to database. I count on your expertise to cut through irrelevant code right to few lines where corrections are needed... I compressed it to only 85 or so lines :-)
The plan is to have tree fully collapsed initially. Then as user opens nodes in search for the one s/he needs up to 6 levels will be available (in my sample I put only 3 - I hope to be able to expand from 3 to 6 myself). Tree should have text from SAP_Func_Loc shown on page, not value of the "SO" field...
I upload the latest code - it now does populate the tree, but
1) It opens the page with the tree fully expanded (thus takes quite some time). I need it to open collapsed and populate nodes by demand when user clicks;
2) It still shows values from "SO" not from "SAP_Func_Loc" - it should be other way around...
3) can I control vertical spacing between nodes? They seem to spread too far, I would like them to be tighter...
Yes, that is exactly where would like to end up...
as user clicks on the plus sign next to a node, it should dynamically load next level children for that parent only...
but when user clicks on the text itself, it should accept it as the "SelectedValue" and not expand anything anymore... in another words user should be able to stop navigation by clicking on text and not be forced to go all the way down tree structure to a leaf...
I assume that is a standard behavior for tree view control, is it so?
any samples floating around?
You are talking about standard behavior for a TreeView, but we can't assume that all behavior may be achievable with a web control. I don't know of any way to override the default behavior of click on node text to select the TreeNode.
The TreeNode has the PopulateOnDemand, that I haven't used. The TreeView has the PopulateNodesFromClient property. You would define an event handler for the TreeView.TreeNodePopulate event handler.
Hmmm...there is the TreeNode.SelectAction property:
http://msdn.microsoft.com/
TreeNodeSelectAction.Expan
--------------------------
Toggles the node between expanded and collapsed. Raises the TreeNodeExpanded event or the TreeNodeCollapsed event as appropriate.
TreeNodeSelectAction.None
--------------------------
Raises no events when a node is selected.
TreeNodeSelectAction.Selec
--------------------------
Raises the SelectedNodeChanged event when a node is selected.
TreeNodeSelectAction.Selec
--------------------------
Raises both the SelectedNodeChanged and the TreeNodeExpanded events when a node is selected. Nodes are only expanded, never collapsed.
Below is the code I ended up with.
Works fine ONLY if user clicks on the node TEXT to expand it (which is something my users can live with). If they click on a plus sign control stops working and they have to reload the page to get it "right".
I tried investigate and looks like TreeNodeCheckChanged event is never raised - do not know why.
Thanks for your help anyway, it was helpful.
Business Accounts
Answer for Membership
by: dhansmaniPosted on 2009-10-15 at 03:48:58ID: 25579165
Hi,
Iam in need of clarifications from you. To bind the tree view u want to get data from database or from the XML.where Xml is the dynamic or static creation ?