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

Total Post:70

Points:350

C#
 3310  View(s)
Ratings:
Rate this:
  1. 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 Mar-29-2018 12:07:41 AM

Answer