Search code examples
c#radio-buttonsql-server-cesqlcedatareader

Display SQL information on C# RadioButtons


My C# program is connected to my SQL CE Database. I use a SQLCEDATAREADER to fill some of the textboxes in my program. I have a "Gender" column in my database and a radiobutton with Male and Female. If a certain entry in my database has "M" in the gender column, how can I make the Male radio button appear pressed?

I tried

if(dr["Gender"].ToString = "M")
{
    rbMale = true
}

That obviously didnt work.


Solution

  • if(dr["Gender"].ToString() = "M")
        rbMale.Checked = true
    else
        rbFemale.Checked = true