易截截图软件、单文件、免安装、纯绿色、仅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");


相关文档:

PHP+DOM创建XML文件

创建文档类型声明
一般而言,XML声明放在文档顶部。在PHP中声明十分简单:只需实例化一个DOM文档类的对象并赋予它一个版本号。查看程序清单A:
程序清单 A
<?php
// create doctype
$dom = new DOMDocument("1.0");
// display document in browser as plain text
// display document in browser as plain text ......

使用 XStream 在 JavaBean 与 XML/JSON 之间相互转换

XML 和 JSON 是当今常用的两种数据描述与传输的格式,特别是涉及到 JS 时使用 JSON 颇为频繁。自然,在 Java  的世界里少不了完成 JavaBean 与这两种格式相互转换的组件,那就是 XStream 和 JSON-lib。这里我简单记下 XStream  的用法。
其实相类似的工具早已有之。如果用过 DWR 的同志,一定有印像,DWR 进行远 ......

防止ASP.NET按钮多次提交的办法

 
 对“添加”、“提交”、“保存”、“更新”等按钮需要对数据库进行写操作的按钮,一定要在页面初始化时加载脚本,防止多次重复点击,例如:
   protected void Page_Load(object sender, EventArgs e)
{
//.net 2.0以上
......

Asp.net中把cs文件编译成dll

上次我们说到的编译成的dll文件与cs文件在同一目录中,而不会放到虚拟目录的bin目录中,如何做才能够把cs
文件编译成dll且自动放到虚拟目录的bin文件夹中呢?
开始-------程序-------Microsoft Visual Studio.NET 2003-------Visual Studio.NET工具,点击其中的“Visual Studio.NET2003命令提示”,就会进入Mic ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号