ASP.NET - Hashtable 对象
2008-09-28 11:21
176 查看
创建 Hashtable
Hashtable 对象包含用键/值对表示的项目。键被用作索引,通过搜索其键,可以实现对值的快速搜索。通过 Add() 方法向 Hashtable 添加项目。
下面的代码创建一个名为 mycountries 的 Hashtable,并添加了四个元素:
<script runat="server"> sub Page_Load if Not Page.IsPostBack then dim mycountries=New Hashtable mycountries.Add("C","China") mycountries.Add("S","Sweden") mycountries.Add("F","France") mycountries.Add("I","Italy") rb.DataSource=mycountries rb.DataValueField="Key" rb.DataTextField="Value" rb.DataBind() end if end sub sub displayMessage(s as Object,e As EventArgs) lbl1.text="Your favorite country is: " & rb.SelectedItem.Text end sub </script> <html> <body> <form runat="server"> <asp:RadioButtonList id="rb" runat="server" AutoPostBack="True" onSelectedIndexChanged="displayMessage" /> <p><asp:label id="lbl1" runat="server" /></p> </form> </body> </html>
相关文章推荐
- 实例讲解ASP.net中Hashtable对象 Hashtable对象是什么?
- ASP.NET – Hashtable 对象
- ASP.NET 2.0 - 善用 SqlDataSource 对象的 CancelSelectOnNullParameter 属性
- ASP.NET 页面对象模型
- asp.net 对象名 '表名' 无效。
- Asp.net MVC中提交集合对象,实现Model绑定
- ASP.NET中application对象
- ASP.NET 内置对象
- asp.net六大对象
- ASP.NET内置对象
- ASP.NET 页面对象模型
- asp.net基于HashTable实现购物车的方法
- asp.net基于HashTable实现购物车的方法
- asp.net web c# 调用 c++ dll库 c++转c#对象错误 海康SDK
- ASP.NET 常用内置对象详解-----Response
- asp.net OracleDataReader对象读取数据异常
- ASP.NET开发中的五大对象
- 如何从Asp.net应用程序中移除所有Cache对象
- ASP.NET - The Hashtable Object
- asp.net 六大内置对象