现在有两个RadioButton,id分别为man,women.在sex组里面。
现在如果选择了男,那么该如何读取出呢?
asp.net如何取RadioButton的值?
答案:5 悬赏:20
解决时间 2021-02-02 22:47
- 提问者网友:斯文败类
- 2021-02-02 03:37
最佳答案
- 二级知识专家网友:兮沫♡晨曦
- 2021-02-02 04:00
//判断是哪个选中,。。。
if (RadioButtonman.Checked)
{
//获取选中的值
string aa = RadioButtonman.Text;
//GG
}
else
{
//获取选中的值
string aa = RadioButtonwomen.Text;
//就是 MM 咯。。
}
if (RadioButtonman.Checked)
{
//获取选中的值
string aa = RadioButtonman.Text;
//GG
}
else
{
//获取选中的值
string aa = RadioButtonwomen.Text;
//就是 MM 咯。。
}
全部回答
- 1楼网友:野心和家
- 2021-02-02 08:10
string str="";
foreach(Control ctl in this.Controls[1].Controls)
{
if(ctl is RadioButton)
{
RadioButton rbt = (RadioButton) ctl;
if(rbt.Checked==true)
{
str=rbt.Text;
}
}
}
- 2楼网友:寂寞的炫耀
- 2021-02-02 07:01
radiobutton1,男
radiobutton2,女
写入数据库的性别(sex)列;
if(radiobutton1.checked)
{
sex="男";
}
if (radiobutton2.checked)
{
sex = "女";
}
- 3楼网友:为你轻狂半世殇
- 2021-02-02 06:52
string sex = "";//定义一个名为sex的空的字符串
if(this.radiobutton.checkd)//如果radiobutton这个控件被选中
{
string sex = this.radiobutton.selectvalue;//获取控件的值。
}
- 4楼网友:一起来看看吧
- 2021-02-02 05:23
string name=string.Empty;
name=man.checked?man.text:women.text
如果男的选择了,就是男的,如果女的选择了就是女的
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯