Asp.net mvc @html.radiobutton如何设置真实状态?

Asp.net mvc @html.radiobutton如何设置真实状态?,asp.net-mvc,razor,html.radiobuttonlist,Asp.net Mvc,Razor,Html.radiobuttonlist,我需要设置@html.radiobutton的真实状态。我有两个单选按钮。一种是真实状态,另一种是虚假状态。我是如何做到的?您可以拥有一个视图模型: public class MyViewModel { public bool Status { get; set; } } 和视图中的2个单选按钮: @Html.RadioButtonFor(x => x.Status, "true") @Html.RadioButtonFor(x => x.Status, "false")

我需要设置@html.radiobutton的真实状态。我有两个单选按钮。一种是真实状态,另一种是虚假状态。我是如何做到的?

您可以拥有一个视图模型:

public class MyViewModel
{
    public bool Status { get; set; }
}
和视图中的2个单选按钮:

@Html.RadioButtonFor(x => x.Status, "true")
@Html.RadioButtonFor(x => x.Status, "false")