日期:2014-05-18  浏览次数:20729 次

radiobutton使用
我用radiobutton做性别,然后想将被选中的性别提交到数据库,但是注册表中没有性别的数据,请帮我指点指点!
 public string radioText;
......................
strSql = "insert into 注册表(用户名,密码,确认密码,公司名称,公司税号,负责人,性别,固定电话,手机号码,Email,传真,详细地址) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + radioText + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "')";

protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
  {
  if (RadioButton1.Checked)
  {
  radioText = "男";
  }
  else
  {
  radioText = "女";
  }

------解决方案--------------------
if (RadioButton1.Checked) 

radioText = "男"; 

else 

radioText = "女"; 


这段代码应该写在两个Radiobutton事件当中
------解决方案--------------------
你可以把 

 if (RadioButton1.Checked) 

radioText = "男"; 

else 

radioText = "女"; 


放到Button 事件当中 不要写到RadioButton1事件中

 string sex;
//获取性别
if (RadioButton1.Checked)
{
sex = "男";
}
else
{
sex= "女";
}