首页 > 编程 > .NET > 正文

ASP.NET简单整理收藏(2)

2024-07-10 12:55:19
字体:
来源:转载
供稿:网友
 

//查询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);
}


商业源码热门下载www.html.org.cn

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表