易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net 读取Xml文件并进行DropDownList数据绑定

<asp:DropDownList ID="compactType" runat="server" AutoCallBack="True" Width="153px"> </asp:DropDownList>

<?xml version="1.0" encoding="utf-8" ?>
<roots>
<root>
<id>1</id>
<Culture>初中以下</Culture>
</root>
<root>
<id>2</id>
<Culture>初中</Culture>
</root>
<root>
<id>3</id>
<Culture>中专</Culture>
</root>
<root>
<id>4</id>
<Culture>高中</Culture>
</root>
<root>
<id>5</id>
<Culture>大专</Culture>
</root>
<root>
<id>6</id>
<Culture>本科</Culture>
</root>
</roots>

/// <summary>
/// 读取xml文件,用数据填充DropDownList,进行绑定
/// </summary>
/// <param name="path">xml文件路径</param>
/// <param name="dp">要进行绑定的DropDownList名称</param>
/// <param name="id">DropDownList要显示的文本(xml文件的一个节点)</param>
/// <param name="val">DropDownList要显示的值(xml文件的一个节点)</param>
public void ReadXml(string path,DropDownList dp,string id,string val)
{
DataSet ds = new DataSet();
ds.ReadXml(path);
dp.DataSource = ds;
dp.DataTextField = id ;
dp.DataValueField = val;
dp.DataBind();
}

SecurityFactory sf = new SecurityFactory();
//xml文件路径
string path2 = Server.MapPath("./xml/XMLFile2.xml");
sf.ReadXml(path2, this.compactType, "id", "val");


相关文档:

c# 读写XML文件

   用c#给PDA做了一个PC端的通讯程序,需要保存两个参数。用Delphi时,是保存在ini文件中,c#读写XML比较方便,就用xml文件来保存了。
   
 
class CXmlClass
{
private string XmlFilePath;
/// <summary>
/// 下载到PDA的TXT文件路径 
/// </summary>
......

XML字符串和XML文档之间的自由转换

本文系转载,谨向转载处空间拥有者及源出处文章作者表示感谢!
转载处:http://henry19890701.javaeye.com/blog/481462
源出处:http://www.ziliaonet.com/tech/netprogramme/XML/200605/69398.html
在做一般的XML数据交换过程中,我更乐意传递XML字符串,而不是格式化的XML Document。这就涉及到XML字符串和Xml Docume ......

支持几乎所有浏览器的js载入xml文件

1.route.xml文件内容
<?xml version="1.0" encoding="GBK"?>
<root>
<route id="1111">
<id>111</id>
<name>四川</name>
<path>www.baidu.com/hehe.html</path>
</route>
</root>
2.test.html代码
<html>
<body>
<script> ......

C# Xml中映射为类数据结构(报文)

        [System.Runtime.Serialization.DataMemberAttribute()]
        public Information Archive {
            get {
         &n ......

asp.net 中 Eval的使用

<asp:TemplateField HeaderText="测试">
<ItemTemplate>
<asp:LinkButton ID="test" runat="server" OnClick="test_Click" OnClientClick='<%# string.Format("return confirmDelete(\"{0} {1}\");", DoEscape((string)Eval( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号