How to Set RadioButtonFor() in ASp.net MVC 2 as Checked by default

coolguy97 picture coolguy97 · Apr 8, 2010 · Viewed 129.6k times · Source

How can i Set RadioButtonFor() as Checked By Default

<%=Html.RadioButtonFor(m => m.Gender,"Male")%>

there is way out for (Html.RadioButton) but not for (Html.RadioButtonFor)

any Ideas?

Answer

Gabriel Militello picture Gabriel Militello · Aug 27, 2010

Use the simple way:

<%= Html.RadioButtonFor(m => m.Gender, "Male", new { Checked = "checked" })%>