我有一个 MVC 视图模型,其中我有可为空的布尔属性:
[DisplayName("Is Active")]
public bool? IsActive { get; set; }
看法:
<div class="col-md-3">
<div class="row">
<label>@Html.LabelFor(model => model.IsActive)</label>
</div>
@Html.RadioButtonFor(model => model.IsActive, true, new {id = "IsIsActiveTrue" })
<label>Yes</label>
@Html.RadioButtonFor(model => model.IsActive, false, new {id = "IsIsActiveFalse" })
<label>No</label>
@Html.RadioButtonFor(model => model.IsActive, "", new {id = "IsIsActiveAll"})
<label>All</label>
</div>
默认情况下,我想在页面加载时选择全部。我试图添加
@checked = "已检查"
但它不起作用(选择了任何单选按钮值)。请指教。