Treeview from database


S

Swede.Swede

Hello!

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:
OrgID
ParentOrgID
CompanyName

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

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


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

<MyHier>
<OrgID>3381416</OrgID>
<CompanyName>Tjurkhults M Fl Byalags Förening</CompanyName>
<MyHier>
<OrgID>3381502</OrgID>
<ParentOrgID>3381416</ParentOrgID>
<CompanyName>Lindebergshult Öndereds Vägsamf.</CompanyName>
<MyHier>
<OrgID>3382268</OrgID>
<ParentOrgID>3381502</ParentOrgID>
<CompanyName>Cöster-Bondick Regine</CompanyName>
</MyHier>
<MyHier>
<OrgID>3381432</OrgID>
<ParentOrgID>3381502</ParentOrgID>
<CompanyName>Med Pro Aps</CompanyName>
</MyHier>
</MyHier>
</MyHier>

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?
 
Ad

Advertisements


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

Top