<%@ Page Language="C#" %>
<!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>Using XML Data Source</title>
</head>
<body>
<div id="pageContent">
<form id="form1" runat="server">
<asp:xmldatasource runat="server" ID="XmlDataSource1" DataFile="Data.xml">
</asp:xmldatasource>
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1">
<DataBindings>
<asp:TreeNodeBinding Depth="3" DataMember="employeeid"
TextField="#innertext" />
<asp:TreeNodeBinding Depth="3" DataMember="lastname"
TextField="#innertext" />
<asp:TreeNodeBinding Depth="3" DataMember="firstname"
TextField="#innertext" />
<asp:TreeNodeBinding Depth="3" DataMember="title"
TextField="#innertext" />
</DataBindings>
</asp:TreeView>
<hr />
<asp:xmldatasource runat="server" ID="XmlDataSource2" DataFile="Data.xml"
xpath="MyDataSet/NorthwindEmployees/Employee" >
</asp:xmldatasource>
<asp:TreeView ID="TreeView2" runat="server" DataSourceID="XmlDataSource2">
<DataBindings>
<asp:TreeNodeBinding Depth="1" DataMember="employeeid"
TextField="#innertext" />
<asp:TreeNodeBinding Depth="1" DataMember="lastname"
TextField="#innertext" />
<asp:TreeNodeBinding Depth="1" DataMember="firstname"
TextField="#innertext" />
<asp:TreeNodeBinding Depth="1" DataMember="title"
TextField="#innertext" />
</DataBindings>
</asp:TreeView>
</form>
</div>
</body>
</html>
File: Data.xml
<?xml version="1.0" standalone="yes"?>
<MyDataSet>
<NorthwindEmployees>
<Employee>
<employeeid>1</employeeid>
<lastname>D</lastname>
<firstname>N</firstname>
<title>Representative</title>
</Employee>
<Employee>
<employeeid>2</employeeid>
<lastname>Fill</lastname>
<firstname>Andrew</firstname>
<title>President</title>
</Employee>
<Employee>
<employeeid>3</employeeid>
<lastname>Lev</lastname>
<firstname>Janet</firstname>
<title>Sales</title>
</Employee>
</NorthwindEmployees>
</MyDataSet>
|