Hopes

          Start Here..

           

          C#中RadioButton分組,和RadioButtonList使用

          C#中RadioButton分組,和RadioButtonList使用

          http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsGroupBoxClassTopic.asp?frame=true

          如果要對RadioButton控件進行分組,就要使用到其GroupName屬性,GroupName值相同的控件被認為是一組的,在同一組RadioButton控件中你始終只能選擇一項,但RadioButton控件的分組屬性GroupName似乎也僅僅是起分組的作用而已,對獲取選中項的值一點幫助都沒有(個人觀點),而使用RadioButtonList似乎是更好的方案,同一個RadioButtonList的選項自然被認為是一組,并且獲取選中項的值也比RadioButton好多了。

          <asp:RadioButtonList runat="server" ID="RadioButtonList1" BorderStyle="None"
                                  RepeatLayout="Flow">
                                  <asp:ListItem>工作日加班</asp:ListItem>
                                  <asp:ListItem>周末加班</asp:ListItem>
                                  <asp:ListItem>法定節日加班</asp:ListItem>
                                  </asp:RadioButtonList>

            “布局”里建議把RepeatLayout改為:Flow

          否則默認是一個table,要寫一個class把table里的td去掉

          .radioButtonList{border-style:none;}
              .radioButtonList tr td{border-style:none;}

            

          判斷取值和 DropDownList一樣,挺方便的。

          if(RadioButtonList1.SelectedIndex == 0){}
           
          RadioButtonList1.SelectedItem.Text.Trim();

          如果想讓后臺代碼默認選中,就在后臺Page_Load()里面加

          this.RadioButtonList1.SelectedIndex = 0;

            

          posted on 2012-08-18 12:23 ** 閱讀(1334) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          公告

          你好!

          常用鏈接

          留言簿(2)

          隨筆檔案

          文章分類

          文章檔案

          新聞檔案

          相冊

          收藏夾

          C#學習

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 台湾省| 东光县| 平罗县| 习水县| 武宣县| 辽阳县| 色达县| 阜新| 桐乡市| 江陵县| 仙桃市| 随州市| 鹤峰县| 米易县| 贵南县| 桑日县| 邵阳县| 虞城县| 修武县| 洪江市| 贵港市| 资源县| 桃源县| 方山县| 丹东市| 大足县| 平阴县| 宕昌县| 阜宁县| 扶风县| 东台市| 南丹县| 民和| 三门县| 英山县| 新龙县| 都匀市| 巩留县| 泾川县| 错那县| 瓮安县|