ASP.NET簡單整理收藏(2)

來源:互聯網
上載者:User
asp.net  

//查詢xml(C#)
DataSet strxml=new DataSet();
string path="XMLFile1.xml";
strxml.ReadXml(Server.MapPath(path));
this.TextBox1.Text=strxml.Tables[0].Rows[0]["sqlchaxun"].ToString();
this.TextBox2.Text=strxml.Tables[0].Rows[1]["sqlchaxun"].ToString();
//XMLFile1.xml
<?xml version="1.0" encoding="utf-8" ?>
<sql>
 <sqlyhtj>
  <sqlchaxun>中華人民共和國</sqlchaxun>
 </sqlyhtj>
 <sqlyhtj>
  <sqlchaxun>中華人民共和國1</sqlchaxun>
 </sqlyhtj>
</sql>

//修改xml(c#)
System.Xml.XmlDocument str1=new System.Xml.XmlDocument();
string path="XMLFile1.xml";
str1.Load(Server.MapPath(path));
System.Xml.XmlNode str2=str1.SelectSingleNode("/sql/sqlyhtj/sqlchaxun");
str2.InnerText=this.TextBox1.Text.Trim();
str1.Save(Server.MapPath(path));
//XMLFile1.xml
<?xml version="1.0" encoding="utf-8"?>
<sql>
  <sqlyhtj>
    <sqlchaxun>yaomingchensss</sqlchaxun>
  </sqlyhtj>
</sql>
//讀xml
//xml
<?xml version="1.0" encoding="utf-8"?>
<yhgl>
  <liebiaoxiang>
    <ACTIDNAME>帳號</ACTIDNAME>
    <ACTID>True</ACTID>
    <USRNAMENAME>使用者名稱稱</USRNAMENAME>
    <USRNAME>True</USRNAME>
  </liebiaoxiang>
</yhgl>

this.ACTID.Text=dsread.Tables[0].Rows[0]["ACTIDNAME"].ToString();
this.ACTID.Checked=bool.Parse(dsread.Tables[0].Rows[0]["ACTID"].ToString());
this.USRNAME.Text=dsread.Tables[0].Rows[0]["USRNAMENAME"].ToString();
this.USRNAME.Checked=bool.Parse(dsread.Tables[0].Rows[0]["USRNAME"].ToString());

for(int i=1;i<=46;i++)
{
BoundColumn columni=new BoundColumn();
columni.HeaderText=dsxml.Tables[0].Rows[i]["chinese"].ToString();
columni.DataField=dsxml.Tables[0].Rows[i]["english"].ToString();
columni.HeaderStyle.Wrap=false;
columni.ItemStyle.Wrap=false;  

columni.Visible=bool.Parse(dsyincang.Tables[0].Rows[0][dsxml.Tables[0].Rows[i]["english"].ToString()].ToString());
//欄位標題置中顯示
columni.HeaderStyle.HorizontalAlign=HorizontalAlign.Center;
//列內容居左顯示
columni.ItemStyle.HorizontalAlign=HorizontalAlign.Left;
this.DataGrid1.Columns.Add(coli);
}




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.