We have the below XMl file.
<?xml version="1.0"?>
<SuperProProductList>
<Product ID="1" Name="Chair">
<Price>49.33</Price>
<Available>True</Available>
<Status>3</Status>
</Product>
<Product ID="2" Name="Car">
<Price>43399.55</Price>
<Available>True</Available>
<Status>3</Status>
</Product>
<Product ID="3" Name="Fresh Fruit Basket">
<Price>49.99</Price>
<Available>False</Available>
<Status>4</Status>
</Product>
</SuperProProductList>
To bind the the above XML to a TreeView use the below code.
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="productListXML"
AutoGenerateDataBindings="False">
<DataBindings>
<asp:TreeNodeBinding DataMember="SuperProProductList" Text="Product List" />
<asp:TreeNodeBinding DataMember="Available" TextField="#InnerText" />
<asp:TreeNodeBinding DataMember="Product" TextField="Name" />
<asp:TreeNodeBinding DataMember="Price" TextField="#InnerText" />
</DataBindings>
</asp:TreeView>
<asp:XmlDataSource ID="productListXML" runat="server"
DataFile="~/productListXML.xml"></asp:XmlDataSource>
Output:
Sunday, January 20, 2013
Binding a XML DataSource to a TreeView
Subscribe to:
Post Comments (Atom)
No comments:
Write comments