如图:
控件1.GroupBox
Groupbox.Text = "性别";
name : gbox_Gbox_friend控件2,3 RadioButton
RadioButton1.Text = "男";
RadioButton2.Text = "女";
name 1: rbutton_Boy_friend
name 2: rbutton_Girl_friend
我的问题是:
我想把 当用户选中的男或者女的时候,把该值传递给存储过程参数 @friend_sex;
comm.Parameters.Add("@friend_sex", SqlDbType.VarChar, 50).Value = gbox_Gbox_friend.ch
comm.Parameters.Add("@friend_sex", SqlDbType.VarChar, 50).Value 是自己写的.
不知道怎么赋值给它.
望老同学们,教教
控件1.GroupBox
Groupbox.Text = "性别";
name : gbox_Gbox_friend控件2,3 RadioButton
RadioButton1.Text = "男";
RadioButton2.Text = "女";
name 1: rbutton_Boy_friend
name 2: rbutton_Girl_friend
我的问题是:
我想把 当用户选中的男或者女的时候,把该值传递给存储过程参数 @friend_sex;
comm.Parameters.Add("@friend_sex", SqlDbType.VarChar, 50).Value = gbox_Gbox_friend.ch
comm.Parameters.Add("@friend_sex", SqlDbType.VarChar, 50).Value 是自己写的.
不知道怎么赋值给它.
望老同学们,教教
SqlParameter parameSex = new SqlParameter("@friend_sex", SqlDbType.VarChar, 50)
parameSex.Value = RadioButton.Text;
comm.Parameters.Add(parameSex);
comm.Parameters.Add("@friend_sex", SqlDbType.VarChar, 50).Value = RadioButton.Text;
可是,RadioButton 根本就没有 Text属性.
RadioButton1或者RadioButton2 才有 Text.
即便有,那怎么判断 用户选择了是 男还是女
if(RadioButton1.Checked)
{
sex = RadioButton1.Text;
}
else if(RadioButton2.Checked)
{
sex = RadioButton2.Text;
}
comm.Parameters.Add("@friend_sex", SqlDbType.VarChar, 50).Value = sex;