Radio button control

Posted by Seger under ASP.NET on 7/13/2010 | Views : 1570 | Status : [Member] | Replies : 6
I have a field in aspx page called gender when i click on one radio button it should get updated in sql databse..pls.guide me..




Responses

Posted by: BangaruBabu on: 7/13/2010 [Member] Starter

Up
0
Down
Under Button Click

string gender=radiobutto1.SelectedItem.Text;


Sqlcommand cmd=new SqlCommand("insert into emp(gender)values('"+gender+"')",conStr);

cmd.ExecuteNonQuery();


BangaruBabu Pureti
http://bangarubabupureti.spaces.live.com/

Seger, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seger on: 7/13/2010 [Member] Starter

Up
0
Down
thanks a lot for ur revert..

in which event is it on page load or button click

Seger, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seger on: 7/13/2010 [Member] Starter

Up
0
Down
conn.Open();
cmd.Connection = conn;
cmd.CommandText = "insert into employeedetail values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "''"+s+"','" + TextBox10.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "')";
cmd.ExecuteNonQuery();
conn.Close();
Response.Write("<script>alert('record added')</script>");
Response.Redirect("Employee Official Detail.aspx");


I have all the fields in my database so i need to update the gender as male or female in my databse.here fourth column is gender i have represented as "s".

Seger, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Paurush83 on: 7/14/2010 [Member] Starter

Up
0
Down
You should take event CheckedChanged of radioButton.
then get the Value/text whatever you want like this.
string sGenderText = RadioButton1.text.

Make a Query for Update :
string sQuery = Update TableName set columnname = Value where condition.

conn.Open();
cmd.Connection = conn;

cmd.ExecuteNonQuery();
conn.Close();


Paurush Sharma

Seger, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeks on: 7/15/2010 [Member] Bronze

Up
0
Down
Please check the IsPostback property before sending to the database using the Button click,

Or, it depends on your requirement when you want to save in database

Seger, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seger on: 7/16/2010 [Member] Starter

Up
0
Down
thnkx.....i got it..

Seger, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response