HOW TO USE RADIO BUTTON ( FOR MALE AND FEMALE ) IN THE FORM APPLICATION IN C#?

Abhishek Srivasatava

Total Post:70

Points:350
Posted by  Abhishek Srivasatava
C#
 428  View(s)
Ratings:
Rate this:
  1. Abhishek Srivasatava

    Post:70

    Points:350
    How to use Radio button ( For male and female ) in the form application in C#?

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!