• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 895
  • Last Modified:

Binding xml data to TreeView control?

Can anyone provide a code sample on how to bind xml data to a TreeView control. (Or any other control, but I want to be able to expand and collapse nodes)

The structure of the xml data is not known/not pre-defined, it varies a lot.
0
dj_user2
Asked:
dj_user2
1 Solution
 
aprestoCommented:
This should help. Once you bind to the tree view control, you wll have all of the functionality of that control available to you as long as the data structure you provide enforces some kind of heirarchy
http://www.c-sharpcorner.com/UploadFile/manishkdwivedi/treeviewcontrol01072008003526AM/treeviewcontrol.aspx 
0
 
rajeeshmcaCommented:
HI dj_user2,

Refer the following link. This contains how to bind xml with treeview, both static and dynamic

http://www.15seconds.com/issue/041117.htm
0
 
aplusexpertCommented:
Hi,

Just load dataset from XML file and bind with tree view control.

Thanks.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
dj_user2Author Commented:
Like mentioned in the OP, we don't know what nodes, values, and attributes the xml data has. Both links assumes xml data format is known to the user.

Binding the xml data to the treeview is displaying just the node names, not the node values.
0
 
rajeeshmcaCommented:
this link does have the way of creating dynamic nodes
check it out
http://www.15seconds.com/issue/041117.htm
0
 
dj_user2Author Commented:
Being able to create notes dynamically is not our requirement. We already have all the data in xml format. I just want to bind it to the tree view control, and be able to expand, collapse, view all the nodes and values.

The article you mentioned creates nodes dynamically from a database table, looping through each row and each field.
0
 
dj_user2Author Commented:
if there is no way to bind xml data to treeview control straight up, I may have to create nodes dynamically; read each xml node, create a tree node, and add it to the treeview control. That's the code sample I am asking for.
0
 
DagdasonCommented:
Which version of .NET Framework? The newer versions are a bit more complicated than .NET 1.1
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now