Link to home
Start Free TrialLog in
Avatar of dj_user2
dj_user2

asked on

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.
Avatar of apresto
apresto
Flag of Italy image

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 
Avatar of rajeeshmca
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
Avatar of aplusexpert
aplusexpert

Hi,

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

Thanks.
Avatar of dj_user2

ASKER

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.
this link does have the way of creating dynamic nodes
check it out
http://www.15seconds.com/issue/041117.htm
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.
ASKER CERTIFIED SOLUTION
Avatar of dj_user2
dj_user2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Which version of .NET Framework? The newer versions are a bit more complicated than .NET 1.1