<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # ASP.NET Web Forms - Hashtable 對象 Hashtable 對象包含用鍵/值對表示的項目。 ![Examples](https://box.kancloud.cn/2015-12-13_566d2e39b7d59.gif) ## 嘗試一下 - 實例 [Hashtable RadiobuttonList 1](/try/showaspx.php?filename=demo_hashtable_radio1) [Hashtable RadiobuttonList 2](/try/showaspx.php?filename=demo_hashtable_radio2) [Hashtable DropDownList](/try/showaspx.php?filename=demo_hashtable_drop1) ## 創建 Hashtable Hashtable 對象包含用鍵/值對表示的項目。鍵被用作索引,通過搜索鍵,可以實現對值的快速搜索。 通過 Add() 方法向 Hashtable 添加項目。 下面的代碼創建了一個名為 mycountries 的 Hashtable 對象,并添加了四個元素: ``` <script runat="server"> Sub Page_Load if Not Page.IsPostBack then dim mycountries=New Hashtable mycountries.Add("N","Norway") mycountries.Add("S","Sweden") mycountries.Add("F","France") mycountries.Add("I","Italy") end if end sub </script> ``` ## 數據綁定 Hashtable 對象可為下列的控件自動生成文本和值: * 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 Hashtable 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 Hashtable 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_hashtable_radio1) **注釋:**您無法選擇添加到 Hashtable 的項目的排序方式。如需對項目進行字母排序或者數字排序,請使用 SortedList 對象。
                  <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>

                              哎呀哎呀视频在线观看