Method 1: aspx frontend binding
Copy codeThe Code is as follows:
<Asp: XmlDataSource ID = "xmlperformance1" runat = "server" DataFile = "~ /SaveFile/test2.xml "> </asp: XmlDataSource>
<Asp: Repeater runat = "server" ID = "Rpt1" performanceid = "xmlperformance1">
<HeaderTemplate>
<Table width = "100%" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<Td> ID </td>
<Td> name </td>
<Td> Number </td>
<Td> date </td>
<Td> CheckIn </td>
<Td> CheckOut </td>
</Tr>
</HeaderTemplate>
<ItemTemplate>
<Tr>
<Td> <% # XPath ("ID") %> </td>
<Td> <% # XPath ("name") %> </td>
<Td> <% # XPath ("Number") %> </td>
<Td> <% # XPath ("date") %> </td>
<Td> <% # XPath ("CheckIn") %> </td>
<Td> <% # XPath ("CheckOut") %> </td>
</Tr>
</ItemTemplate>
<FooterTemplate>
</Table>
</FooterTemplate>
</Asp: Repeater>
Method 2: bind DataSource
Aspx
Copy codeThe Code is as follows:
<Asp: Repeater runat = "server" ID = "Rpt1">
<HeaderTemplate>
<Table width = "100%" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<Td> ID </td>
<Td> name </td>
<Td> Number </td>
<Td> date </td>
<Td> CheckIn </td>
<Td> CheckOut </td>
</Tr>
</HeaderTemplate>
<ItemTemplate>
<Tr>
<Td> <% # Eval ("ID") %> </td>
<Td> <% # Eval ("name") %> </td>
<Td> <% # Eval ("Number") %> </td>
<Td> <% # Eval ("date") %> </td>
<Td> <% # Eval ("CheckIn") %> </td>
<Td> <% # Eval ("CheckOut") %> </td>
</Tr>
</ItemTemplate>
<FooterTemplate>
</Table>
</FooterTemplate>
</Asp: Repeater>
Aspx. cs
Copy codeThe Code is as follows:
Protected void Page_Load (object sender, EventArgs e)
{
If (! IsPostBack)
{
DataSet ds = new DataSet ();
Ds. ReadXml (Server. MapPath (@"~ \ SaveFile \ test2.xml "));
Rpt1.DataSource = ds;
Rpt1.DataBind ();
}
}