首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> ASP.NET 基礎 >> 關於ASP.NET

資料繫結技巧:XML 檔案作為資料來源繫結至控件

     編輯:關於ASP.NET

XML 檔案 people.xml:

<People>
  <Person><Name>張三</Name><Phone>66666666</Phone><Address>北京市海澱區</Address></Person>
  <Person><Name>李四</Name><Phone>88888888</Phone><Address>北京市豐台區</Address></Person>
  <Person><Name>王五</Name><Phone>99999999</Phone><Address>北京市朝陽區</Address></Person>
</People>

程式碼:

void Page_Load(object sender, System.EventArgs e)
{
    DataSet myDS = new DataSet();
    myDS.ReadXml(Server.MapPath("people.xml"));
    Label1.Text = "表的名稱是:" + myDS.Tables[0].TableName;
    DataGrid1.DataSource = myDS.Tables[0];
    DataGrid1.DataBind();
}

來源:https://mjgforever.cnblogs.com/

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved