<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # ASP.NET Web Forms - SortedList 對象 SortedList 對象結合了 ArrayList 對象和 Hashtable 對象的特性。 ![Examples](https://box.kancloud.cn/2015-12-13_566d2e39b7d59.gif) ## 嘗試一下 - 實例 [SortedList RadiobuttonList 1](/try/showaspx.php?filename=demo_sortedlist_radio1) [SortedList RadiobuttonList 2](/try/showaspx.php?filename=demo_sortedlist_radio2) [SortedList DropDownList](/try/showaspx.php?filename=demo_sortedlist_drop1) ## SortedList 對象 SortedList 對象包含用鍵/值對表示的項目。SortedList 對象按照字母順序或者數字順序自動地對項目進行排序。 通過 Add() 方法向 SortedList 添加項目。通過 TrimToSize() 方法把 SortedList 調整為最終尺寸。 下面的代碼創建了一個名為 mycountries 的 SortedList 對象,并添加了四個元素: ``` <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 對象可為下列的控件自動生成文本和值: * asp:RadioButtonList * asp:CheckBoxList * asp:DropDownList * asp:Listbox 為了綁定數據到 RadioButtonList 控件,首先要在 .aspx 頁面中創建一個 RadioButtonList 控件(不帶任何 asp:ListItem 元素): ``` <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 sub </script> <html> <body> <form runat="server"> <asp:RadioButtonList id="rb" runat="server" AutoPostBack="True" /> </form> </body> </html> ``` 然后我們添加一個子例程,當用戶點擊 RadioButtonList 控件中的某個項目時,該子例程會被執行。當某個單選按鈕被點擊時,label 中會出現一行文本: ## 實例 ``` <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 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> ``` [演示實例 ?](/try/showaspx.php?filename=demo_sortedlist_radio1)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看