【www.gdgbn.com--面向对象编程】

net 教程:ASP.NET SortedList 对象

SortedList对象的特点相结合的ArrayList的对象和哈希表对象。

在SortedList对象
在SortedList对象包含项目的键/值对。阿SortedList自动排序对象中的项目字母或数字顺序。

项目新增至SortedList与购买( )方法。阿SortedList尺寸可作其最后大小与TrimToSize ( )方法。

下面的代码创建了一个SortedList命名mycountries和四个要素说:

<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
  dim mycountries=New SortedList
  mycountries.Add("N","Norway")
  mycountries.Add("S","Sweden")
  mycountries.Add("F","France")
  mycountries.Add("I","Italy")
end if
end sub
</script>
数据绑定阿SortedList对象可自动生成的文字和价值观下列管制: 动态: RadioButtonList 动态: CheckBoxList 动态:下拉列表动态:列表框绑定数据到RadioButtonList控件,首先创建一个RadioButtonList控件(无任何ASP :ListItem元素)的。 aspx页:html>


AutoPostBack="True" />

< ml>然后添加脚本,建立名单:<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
  dim mycountries=New SortedList
  mycountries.Add("N","Norway")
  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
</script>

AutoPostBack="True" />

< ml>

本文来源:http://www.gdgbn.com/jsp/17281/