<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>XML Data Binding</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:XmlDataSource ID="sourceXml"
runat="server"
DataFile="data.xml" />
<asp:GridView ID="GridView1"
runat="server"
AutoGenerateColumns="True"
DataSourceID="sourceXml"
Visible="False"/>
<br />
<asp:TreeView ID="TreeView1"
runat="server"
DataSourceID="sourceXml">
<DataBindings>
<asp:TreeNodeBinding DataMember="SuperProProductList" Text="Product List" />
<asp:TreeNodeBinding DataMember="Category" TextField="Name" />
<asp:TreeNodeBinding DataMember="Product" TextField="Name" />
<asp:TreeNodeBinding DataMember="Price" TextField="#InnerText" />
</DataBindings>
</asp:TreeView>
</div>
</form>
</body>
</html>
File: data.xml
<?xml version="1.0" standalone="yes"?>
<SuperProProductList xmlns="SuperProProductList" >
<Category Name="Hardware">
<Product ID="1" Name="Chair">
<Price>49.33</Price>
</Product>
<Product ID="2" Name="Car">
<Price>43398.55</Price>
</Product>
</Category>
<Category Name="Produce">
<Product ID="3" Name="PC">
<Price>49.99</Price>
</Product>
</Category>
</SuperProProductList>
|