当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP.NET > ASP.NET - The SortedList Object 可排序列表对象
The SortedList object combines the features of both the ArrayList object and the Hashtable object.
可排序列表对象结合了数组列表对象以及哈希表对象的特点。
Example 1 - SortedList RadioButtonList
Example 2 - SortedList RadiobuttonList
Example 3 - SortedList DropDownList
The SortedList object contains items in key/value pairs. A SortedList object automatically sort the items in alphabetic or numeric order.
可排序列表对象对象包含项目中的 键/值 对。可排序列表对象可自动的以字母或是数字来进行排序。
Items are added to the SortedList with the Add() method. A SortedList can be sized to its final size with the TrimToSize() method.
使用Add()方法可以将项目填加到可排序列表对象中。可排序列表可以使用TrimToSize()方法来将大小调整到最后的大小。
The following code creates a SortedList named mycountries and four elements are added:
下面的代码会建立一个可排序列表,名称为 mycountries 并且加入了四个元素:
<script runat="server"> |
A SortedList object may automatically generate the text and values to the following controls:
可排序列表对象可以自动的给下面这些控件生成文字以及值:
To bind data to a RadioButtonList control, first create a RadioButtonList control (without any asp:ListItem elements) in an .aspx page:
要被 RadioButtonList 控件绑定数据,首先要在一个.aspx页面中建立 RadioButtonList 控件 (不需要任何asp:ListItem 元素):
<html> <form runat="server"> </body> |
Then add the script that builds the list:
然后加入脚本来生成列:
<script runat="server"> <html> <form runat="server"> </body> |
Then we add a sub routine to be executed when the user clicks on an item in the RadioButtonList control. When a radio button is clicked, a text will appear in a label:
然后我们加入子程序,当用户按下RadioButtonList控件中的项目就会执行。当单选按钮按下后,一段文字就会显示在标签中:
<script runat="server"> sub displayMessage(s as Object,e As EventArgs) <html> <form runat="server"> </body> |