教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Asp.net  >  正文 asp.net入门教程:ASP.NET SortedList 对象教程

asp.net入门教程:ASP.NET SortedList 对象教程

发布时间:2018-10-01   编辑:jiaochengji.com
教程集为您提供asp.net入门教程:ASP.NET SortedList 对象教程等资源,欢迎您收藏本站,我们将为您提供最新的asp.net入门教程:ASP.NET SortedList 对象教程资源

asp.net入门教程:ASP.NET SortedList 对象教程

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


 

范例
例如1 -S ortedListR adioButtonList

例如2 -S ortedListR adiobuttonList

例如3 -S ortedList下拉列表

 

在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>
<body><form runat="server">
<asp:RadioButtonList id="rb" runat="server"
AutoPostBack="True" /></form></body>
</html>增加.<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><html>
<body><form runat="server">
<asp:RadioButtonList id="rb" runat="server"
AutoPostBack="True" /></form></body>
</html>然后,我们添加一个子例程被处决时,用户点击一个项目RadioButtonList控件。当一个单选按钮被点击,一个文本将出现在一个标签:<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 subsub 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入门教程:ASP.NET SortedList 对象教程
net 教程:ASP.NET SortedList 对象
net入门教程:ASP.NET ArrayList 对象
net入门教程:ASP.NET Hashtable 对象 教程
深入浅出asp.NET泛型编程.NET泛型编程入门教程
ASP.NET 入门的五个步骤
php入门教程(索引)
asp.net 数组操作入门实例
ASP.NET中TreeView控件使用小结
ASP.net的ACCESS数据分页方案

[关闭]
~ ~