两个RadioButton为一组,一个boy,一个girl,当选择一个的时候把text值存到数据库,可我做的不行:(,
private void hand_Click(object sender, System.EventArgs e)
{
string strInsert;
SqlCommand contactInsert;
strInsert = "Insert contact ( name,sex,qq,msn,mail,url,message,date_hand ) Values ( @name,@sex,,@qq,@msn,@mail,@url,@message,@date_hand )";
contactInsert = new SqlCommand( strInsert, sqlConnectionContact );
contactInsert.Parameters.Add( "@name", SqlDbType.Char ).Value = name.Text;
contactInsert.Parameters.Add( "@boy", SqlDbType.Char ).Value = boy.Text;
contactInsert.Parameters.Add( "@sex", SqlDbType.Char ).Value = qq.Text;
contactInsert.Parameters.Add( "@msn", SqlDbType.Char ).Value = msn.Text;
contactInsert.Parameters.Add( "@mail", SqlDbType.Char ).Value = mail.Text;
contactInsert.Parameters.Add( "@url", SqlDbType.Char ).Value = url.Text;
contactInsert.Parameters.Add( "@message", SqlDbType.VarChar ).Value = message.Text;
contactInsert.Parameters.Add( "@date_hand", SqlDbType.DateTime ).Value = DateTime.Now;
sqlConnectionContact.Open();
contactInsert.ExecuteNonQuery();
sqlConnectionContact.Close();
}
<td width="144"><FONT face="ËÎÌå">
<asp:RadioButton id="boy" runat="server" Text="Boy" GroupName="sex"></asp:RadioButton>
<asp:RadioButton id="girl" runat="server" Text="Girl" GroupName="sex"></asp:RadioButton></FONT></td>