Home > DeveloperSection > Interviews > How to use Radio button ( For male and female ) in the form application in C#?

Posted on    October-25-2016 10:50 PM

 C# C#  SQL Server 
Ratings:
 1 Answer(s)
  78  View(s)
Rate this:

Abhishek Srivasatava
Abhishek Srivasatava

Total Post:70

Points:350
Posted on    October-25-2016 10:50 PM

Here is the code to use radio button in C# using SQL.


           if (radioButton1.Checked == true || radioButton2.Checked == true)
            {
                if (radioButton1.Checked == true)
                {
                    savecom.Parameters.AddWithValue("@Sex", "Male");
                }
                else
                {
                    savecom.Parameters.AddWithValue("@Sex", "Female");
                }
            }
            else
            {
                savecom.Parameters.AddWithValue("@Sex", null);
            }


Always use the else case otherwise error shall be come during testing.


Modified On Nov-01-2016 07:34:44 AM

Don't want to miss updates? Please click the below button!

Follow MindStick