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

前端 未结 14 1861
一向
一向 2021-02-06 21:20

How can i Set RadioButtonFor() as Checked By Default

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

there is way out for (Html.Radio

14条回答
  •  心在旅途
    2021-02-06 21:41

    You need to add 'checked' htmlAttribute in RadioButtonFor, if the radiobutton's value matches with Model.Gender value.

    @{
            foreach (var item in Model.GenderList)
            {
                
    } }

    For complete code see below link: To render bootstrap radio button group with default checked. stackoverflow answer link

提交回复
热议问题