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