How to get value of Radio Buttons?

后端 未结 7 1334
自闭症患者
自闭症患者 2020-12-30 05:05

I have a group box contains radio buttons eg.

o Male

o Female

i want my code to get the sel

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-30 05:36

    For Win Forms :

    To get the value (assuming that you want the value, not the text) out of a radio button, you get the Checked property:

    string value = "";
    bool isChecked = radioButton1.Checked;
    if(isChecked )
      value=radioButton1.Text;
    else
      value=radioButton2.Text;
    

    For Web Forms :

    
        Male
        Female
    
    

    And CS-in some button click

    string value=rdoPriceRange.SelectedItem.Value.ToString();
    

提交回复
热议问题