ASP.NET简单整理收藏(2)
2007-05-15 21:20
429 查看
//查询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);
}
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);
}
相关文章推荐
- ASP.NET简单整理收藏(1)
- ASP.NET简单整理收藏(2)
- 简单的ASP.NET无刷新分页 分类: ASP.NET 2012-05-06 02:09 655人阅读 评论(1) 收藏
- 整理的asp.net资料(收藏)
- 一个简单的ASP.NET访问MySql数据库 收藏
- 大年三十整理的asp.net资料!(不得不收藏)
- 《Artech的ASP.NET系列》系列技术文章整理收藏
- 整理的asp.net资料(收藏)
- 强!!整理的asp.net资料!(不得不收藏)
- Asp.Net Core简单整理
- 整理的asp.net资料!(不得不收藏)
- 大年三十整理的asp.net资料!(不得不收藏)
- 转载牛人的ASP.NET Cookies简单应用 记住用户名和密码 收藏
- 整理的asp.net资料(收藏)
- 论坛收藏整理:ASP/ASP.NET
- 【收藏】利用AJAX和ASP.NET实现简单聊天室
- 《微软ASP.NET站点部署指南》系列技术文章整理收藏
- 大年三十整理的asp.net资料!(不得不收藏)(不得不转)
- ASP.NET常用方法收藏整理帖
- 大年三十整理的asp.net资料!(不得不收藏)