<%@ Page Language="C#"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <h2>Nested data bind sample</h2> <asp:DataList ID="_outerDataList" runat="server" DataSourceID="_bookstoreDataSource"> <ItemTemplate> Title: <%# Eval("Title") %><br /> <asp:DataList runat="server" ID="_nestedDastaList" DataSource='<%# XPathSelect("chapter") %>'> <ItemTemplate> <h4>Chapternum: <%# XPath("@num") %></h4> <h4>Chapter name: <%# XPath("@name") %></h4> <%# XPath(".") %> <br /> </ItemTemplate> </asp:DataList> <br /> </ItemTemplate> </asp:DataList> <asp:XmlDataSource ID="_bookstoreDataSource" runat="server" DataFile="~/App_Data/Data.xml" XPath="/Data/genre/book" /> </div> </form> </body> </html> File: Data.xml <Data> <genre name="Business"> <book ISBN="1" Title="Database" Price="19.99"> <chapter num="1" name="Introduction"> Abstract... </chapter> <chapter num="2" name="Body"> Abstract... </chapter> <chapter num="3" name="Conclusion"> Abstract... </chapter> </book> <book ISBN="2" Title="Computer" Price="2.99"> <chapter num="1" name="Introduction"> Abstract... </chapter> <chapter num="2" name="Body"> Abstract... </chapter> <chapter num="3" name="Conclusion"> Abstract... </chapter> </book> <book ISBN="3" Title="VB" Price="19.99"> <chapter num="1" name="Introduction"> Abstract... </chapter> <chapter num="2" name="Body"> Abstract... </chapter> <chapter num="3" name="Conclusion"> Abstract... </chapter> </book> </genre> </Data>