Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to write radiobutton event code in button event....i want to insert data for one radio button on clicking the button and select data for another radio button but bothe codes shd be only in one button event
Posted
Comments
Sandeep Mewara 1-Jun-12 5:39am    
Kinda repost: http://www.codeproject.com/Questions/395776/how-to-set-two-radio-button-options-in-asp-net-csh

Without sharing nay effort. Looks like just seeking for 'exact' code.

To subscribe both events use this code:
C#
public Form1()
{
  InitializeComponent();
  this.radioButton1.Click += new System.EventHandler(this.radioButton_Click);
  this.radioButton2.Click += new System.EventHandler(this.radioButton_Click);
}

To handle the events this should work:
C#
private void radioButton_Click(object sender, EventArgs e)
{
   if ((RadioButton)sender == radioButton1)
   {
      //insert data
   }
   else
   {
      //select data
   }
}
 
Share this answer
 
v2
Please write like this
C#
private void Button1_Click(object sender, EventArgs e)
{
if(radiobutton1.checked)
{
//insert query 1
}
{
//insert query 2
}
}

note:

First set group name for two radiobutton same.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900