Mega Code Archive

 
Categories / ASP.Net / XML
 

XmlDataSource and XML document

<%@ Page Language="C#" AutoEventWireup="false" %> <!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>Untitled Page</title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:XmlDataSource ID="sourceDVD"                             runat="server"                             DataFile="~/Data.xml">         </asp:XmlDataSource>         <asp:GridView ID="GridView1"                        runat="server"                        AutoGenerateColumns="False"                        DataSourceID="sourceDVD">             <Columns>                 <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />                 <asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category" />             </Columns>         </asp:GridView>          </div>     </form> </body> </html> File: Data.xml <?xml version="1.0"?> <DvdList>    <DVD ID="1" Category="Category 1">       <Title>title 1</Title>       <Director>directory 2</Director>       <Price>1</Price>       <Starring>          <Star>star 1</Star>          <Star>star 2</Star>       </Starring>    </DVD>    <DVD ID="2" Category="Category 2">       <Title>title 2</Title>       <Director>directory 2</Director>       <Price>2</Price>       <Starring>          <Star>star 3</Star>          <Star>star 4</Star>       </Starring>    </DVD> </DvdList>