Radio Button doesn't reflect Model's value

耗尽温柔 提交于 2019-12-01 22:16:59

bool type will be render in client like this

true => True
false => False

Have you try to inspect your element rendered in HTML? You'll see that the bool value transform into capitalize string. To overcome this you should change true and false in radio button with type string too.

Your view code should be like this

<label>
   @Html.RadioButtonFor(x => x.BActive, "true", new { @class = "radio-inline" }) Open
</label>
<label>
   @Html.RadioButtonFor(x => x.BActive, "false", new { @class = "radio-inline" }) Close
</label>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!