1 進行初始化
<%=Html.RadioButtonFor(model => model.TypeState, 0, new { @id = "radio2", @name = "rdolstState" })%>啟用
<%=Html.RadioButtonFor(model => model.TypeState, 1, new { @id = "radio1", @name = "rdolstState",@checked=true })%>禁用
注意:htmlAbrritbutes屬性的使用 “new{………………………… }”;
2 編輯時,綁定值,根據數據顯示RadioButtonFor選中狀態
<%=Html.RadioButtonFor(model => model.TypeState, 0, new { @id = "radio2", @name = "rdolstState" })%>啟用
<%=Html.RadioButtonFor(model => model.TypeState, 1, new { @id = "radio1", @name = "rdolstState" })%>禁用
說明:當數據中“TypeState”是0時,這第一條會顯示被選中,反之,就是第二條顯示選中。