I have three radio buttons and my field value type is integer like Maintenance for 3, Active for 1 and Inactive for 2.
@Html.RadioButtonFor(model => model.StatusId, "3") Maintenance
@Html.RadioButtonFor(model => model.StatusId,"1") Active
@Html.RadioButtonFor(model => model.StatusId, "2") Inactive
i using above code then insert data properly but when my form open in edit mode then i have not get any radio button selected.
and i also used below code but not get success.
@Html.RadioButtonFor(model => model.StatusId, "3", Model.StatusId == '3' ? new {Checked = "checked"} : null) Maintenance
@Html.RadioButtonFor(model => model.StatusId, "1",Model.StatusId == '1' ? new {Checked = "checked"} : null) Active}
@Html.RadioButtonFor(model => model.StatusId, "2",Model.StatusId == '2' ? new {Checked = "checked"} : null) Inactive
so how to get selected radio button in edit mode
thanks in advance
Please try with the below code snippet.
@Html.RadioButtonFor(model => model.StatusId, "2", Model.StatusId == '2' ? new {@Checked = "checked"} : '')
OR
@Html.RadioButtonFor(model => model.StatusId, "2", Model.StatusId == '2' ? new {@Checked = "checked"} : null)
If above code is not worked then please provide your rendered html code of this radiobutton/input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With