方法一:aspx前臺(tái)綁定
復(fù)制代碼 代碼如下:
asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/SaveFile/test2.xml">/asp:XmlDataSource>
asp:Repeater runat="server" ID="Rpt1" DataSourceID="XmlDataSource1">
HeaderTemplate>
table width="100%" border="0" cellspacing="0" cellpadding="0">
tr>
td>ID/td>
td>name/td>
td>號碼/td>
td>date/td>
td>CheckIn/td>
td>CheckOut/td>
/tr>
/HeaderTemplate>
ItemTemplate>
tr>
td>%# XPath("ID")%>/td>
td>%# XPath("name")%>/td>
td>%# XPath("號碼")%>/td>
td>%# XPath("date")%>/td>
td>%# XPath("CheckIn")%>/td>
td>%# XPath("CheckOut")%>/td>
/tr>
/ItemTemplate>
FooterTemplate>
/table>
/FooterTemplate>
/asp:Repeater>
方法二:綁定DataSource
aspx
復(fù)制代碼 代碼如下:
asp:Repeater runat="server" ID="Rpt1">
HeaderTemplate>
table width="100%" border="0" cellspacing="0" cellpadding="0">
tr>
td>ID/td>
td>name/td>
td>號碼/td>
td>date/td>
td>CheckIn/td>
td>CheckOut/td>
/tr>
/HeaderTemplate>
ItemTemplate>
tr>
td>%# Eval("ID")%>/td>
td>%# Eval("name")%>/td>
td>%# Eval("號碼")%>/td>
td>%# Eval("date")%>/td>
td>%# Eval("CheckIn")%>/td>
td>%# Eval("CheckOut")%>/td>
/tr>
/ItemTemplate>
FooterTemplate>
/table>
/FooterTemplate>
/asp:Repeater>
aspx.cs
復(fù)制代碼 代碼如下:
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();
}
}
您可能感興趣的文章:- ASP.NET中XML轉(zhuǎn)JSON的方法實(shí)例
- asp.net操作xml增刪改示例分享
- ASP.NET實(shí)現(xiàn)TreeView的XML數(shù)據(jù)源綁定實(shí)例代碼
- ASP.NET+XML打造網(wǎng)絡(luò)硬盤原理分析
- asp.net Linq to Xml學(xué)習(xí)筆記
- asp.net XML文件操作實(shí)現(xiàn)代碼
- Asp.net XML文檔進(jìn)行添加刪改操作的實(shí)例代碼
- asp.net下xml當(dāng)作導(dǎo)航數(shù)據(jù)源實(shí)現(xiàn)動(dòng)態(tài)權(quán)限
- asp.net下將圖片保存到XML文件的方法
- ASP.net處理XML數(shù)據(jù)實(shí)例淺析