how to save radio button value in database in c#
  • how to insert radio button value in database in c#
  • 1 Comment sorted by
  • Vote Up0Vote Down ithackerithacker
    117.50 Karma Accepted Answer
    you can use below code

    SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename="" Integrated Security=True;Connect Timeout=30;User Instance=True");
    con.Open();
    SqlCommand cmd = new SqlCommand("insert into Table1(gender) values(@gender)",con);

    SqlDataAdapter da = new SqlDataAdapter(cmd);


    if(radioButton1.Checked=true)
    {
    cmd.Parameters.AddWithValue("@gender", radioButton1.Text.ToString());

    radioButton2.Checked = false;


    cmd.ExecuteNonQuery();
    con.Close();

    }


    else if(radioButton2.Checked=true)
    {
    cmd.Parameters.AddWithValue("@gender", radioButton2.Text.ToString());
    radioButton1.Checked = false;

    cmd.ExecuteNonQuery();


    con.Close();

    }
    - See more at: http://codingresolved.com/discussion/982/save-radio-button-value-into-database#sthash.I6BY5Q1w.dpuf

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

    Optimum Creative