Treeview from database




I have some data that I want to bind to a treeview. I have the data in
a datatable. The datatable has the following columns:

I cannot bind the datatable directly since the datatable does not
implement IHierarchicalDataSource interface.

What I do is that I create a dataset, adds the table to the dataset
and adds a relation between OrgID and parentID.

Then I use the dataset.GetXML method to get the xml and adds the
result to an xmldatasource which I finally can bind to the treeview!

But the resulting XML from does not suit the treeview control. In
Microsofts examples I have seen this XML

<book title="Secrets of Silicon Valley" author="Sheryl Hunter"/>
<book title="Straight Talk About Computers" author="Dean
<book title="You Can Combat Computer Stress!" author="Marjorie
<book title="Silicon Valley Gastronomic Treats" author="Innes del

But the xml that I get is structured without attributes (MyHier is the
name of the datatable):

<CompanyName>Tjurkhults M Fl Byalags Förening</CompanyName>
<CompanyName>Lindebergshult Öndereds Vägsamf.</CompanyName>
<CompanyName>Cöster-Bondick Regine</CompanyName>
<CompanyName>Med Pro Aps</CompanyName>

This does not result in a correct treeview. Although the structure is
correct regarding parent-child, the nodes are named MyHier, OrgID,
ParentID and so on. No actual values! Any tips?


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

TreeView caching 3