Reputation: 306
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.
Upvotes: 0
Views: 602
Reputation: 68
if(dr["Gender"].ToString() = "M")
rbMale.Checked = true
else
rbFemale.Checked = true
Upvotes: 1
Reputation: 31
Perhaps collapse to one line -
rbMale.Checked = (Convert.ToString(dr["Gender"])=="M");
Upvotes: 1
Reputation: 6357
If rbMale
is the name of your radio button control, you can mark it checked by setting its Checked
property to true
.
rbMale.Checked = true;
Upvotes: 0