<?xml version="1.0" encoding="UTF-8"?> <mydatabase> <customer> <CustomerID>C001</CustomerID> <Name>Win Weerachai</Name> <Email>[email protected]</Email> <CountryCode>TH</CountryCode> <Budget>1000000</Budget> <Used>600000</Used> </customer> <customer> <CustomerID>C002</CustomerID> <Name>John Smith</Name> <Email>[email protected]</Email> <CountryCode>EN</CountryCode> <Budget>2000000</Budget> <Used>800000</Used> </customer> <customer> <CustomerID>C003</CustomerID> <Name>Jame Born</Name> <Email>[email protected]</Email> <CountryCode>US</CountryCode> <Budget>3000000</Budget> <Used>600000</Used> </customer> <customer> <CustomerID>C004</CustomerID> <Name>Chalee Angel</Name> <Email>[email protected]</Email> <CountryCode>US</CountryCode> <Budget>4000000</Budget> <Used>100000</Used> </customer> </mydatabase>
<%@ Import Namespace="System.Data"%> <%@ Page Language="C#" Debug="true" %> <script runat="server"> void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); ds.ReadXml(MapPath("XML/customer.xml")); //*** BindData to Repeater ***// myRepeater.DataSource = ds; myRepeater.DataBind(); } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - XML</title> </head> <body> <form id="form1" runat="server"> <asp:Repeater id="myRepeater" runat="server"> <HeaderTemplate> <table border="1"> <tr> <th>CustomerID</th> <th>Name</th> <th>Email</th> <th>CountryCode</th> <th>Budget</th> <th>Used</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td align="center"><%# DataBinder.Eval(Container.DataItem, "CustomerID") %></td> <td><%# DataBinder.Eval(Container.DataItem, "Name") %></td> <td><%# DataBinder.Eval(Container.DataItem, "Email") %></td> <td align="center"><%# DataBinder.Eval(Container.DataItem, "CountryCode") %></td> <td align="right"><%# DataBinder.Eval(Container.DataItem, "Budget") %></td> <td align="right"><%# DataBinder.Eval(Container.DataItem, "Used") %></td> </tr> </ItemTemplate> <FooterTemplate> <!-- <tr> <th>CustomerID</th> <th>Name</th> <th>Email</th> <th>CountryCode</th> <th>Budget</th> <th>Used</th> </tr> --> </table> </FooterTemplate> </asp:Repeater> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท