ASP MVC Set RadioButton From Database
- by Jacob Huggart
Hello All,
I have what should be an easy question for you today.
I have two radio buttons in my view:
Sex:
<%=Html.RadioButton("Sex", "Male", true)% Male
<%=Html.RadioButton("Sex", "Female", true)% Female
I need to select one based on the value returned from my database. The way I am trying to do it now is:
ViewData["Sex"] = data.Sex; //Set radio button
But that is not working. I have tried every possible combination of isChecked properties. I know that data.Sex is returning either "Male" or "Female". What do I need to do to check the appropriate radio button?