最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ASP.NET - SortedList 對(duì)象

SortedList 對(duì)象兼有 ArrayList 和 Hashtable 對(duì)象的特性。

SortedList 對(duì)象

SortedList 對(duì)象包含用鍵/值對(duì)表示的項(xiàng)目。SortedList 對(duì)象可按照字符順序或數(shù)字順序自動(dòng)地對(duì)項(xiàng)目進(jìn)行排序。

通過(guò) Add() 方法向 SortedList 添加項(xiàng)目。SortedList 可通過(guò) TrimToSize() 方法調(diào)整為最終尺寸。

下面的代碼創(chuàng)建了一個(gè)名為 mycountries 的 SortedList,并添加了四個(gè)元素:

<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
  dim mycountries=New SortedList
  mycountries.Add("C","China")
  mycountries.Add("S","Sweden")
  mycountries.Add("F","France")
  mycountries.Add("I","Italy")
end if
end sub
</script>

數(shù)據(jù)綁定

SortedList 對(duì)象可自動(dòng)地為下面的控件生成文本和值:

  • asp:RadioButtonList
  • asp:CheckBoxList
  • asp:DropDownList
  • asp:Listbox

如需把數(shù)據(jù)綁定到 RadioButtonList 控件,首先請(qǐng)?jiān)?aspx 文件中創(chuàng)建一個(gè) RadioButtonList 控件(沒(méi)有任何 asp:ListItem 元素):

<html>
<body>

<form runat="server">
<asp:RadioButtonList id="rb" runat="server" AutoPostBack="True" />
</form>

</body>
</html>

然后添加構(gòu)建列表的腳本:

<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
  dim mycountries=New SortedList
  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
</script>

<html>
<body>

<form runat="server">
<asp:RadioButtonList id="rb" runat="server" AutoPostBack="True" />
</form>

</body>
</html>

然后我們添加一個(gè)子例程,該子例程會(huì)在用戶點(diǎn)擊 RadioButtonList 控件中的項(xiàng)目時(shí)執(zhí)行。當(dāng)單選按鈕被點(diǎn)擊時(shí),文本將出現(xiàn)在 label 中:

<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
  dim mycountries=New SortedList
  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>

顯示這個(gè)例子

吴堡县| 彝良县| 西充县| 佛冈县| 泗阳县| 高州市| 泽普县| 阳东县| 乐陵市| 荆门市| 家居| 咸宁市| 武胜县| 冷水江市| 佛学| 华亭县| 江孜县| 大足县| 保山市| 南川市| 英超| 陆良县| 赤水市| 珠海市| 高雄县| 名山县| 淄博市| 双辽市| 天柱县| 新民市| 南部县| 凤翔县| 蕲春县| 六盘水市| 鄂伦春自治旗| 松江区| 会同县| 墨脱县| 榆中县| 湟源县| 耿马|