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#學習

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 桐庐县| 鄂托克前旗| 海口市| 石首市| 郁南县| 翁源县| 姜堰市| 涿州市| 怀远县| 格尔木市| 增城市| 定边县| 曲沃县| 牡丹江市| 合川市| 太白县| 天津市| 元朗区| 门源| 聂拉木县| 台湾省| 陇西县| 阿拉尔市| 台南县| 博湖县| 永登县| 陆河县| 如东县| 酒泉市| 黄山市| 赞皇县| 中宁县| 中方县| 四平市| 波密县| 娄烦县| 东乡县| 松潘县| 城固县| 南皮县| 塔河县|