0

を使用して、MVCの1つのモデルプロパティに2つのラジオボタンをバインドするにはどうすればよいですか?@Html.RadioButtonFor()

4

1 に答える 1

0

モデル内:

public class MyModel
{
    public bool? DoYouAgree { get; set; }
}

あなたの見解では:

<label>
    @Html.RadioButtonFor(m => m.DoYouAgree, false, 
        new { id = "DoYouAgree_false" })
    No
</label>
<label>
    @Html.RadioButtonFor(m => m.DoYouAgree, true, 
        new { id = "DoYouAgree_true" })
    Yes
</label>
于 2012-06-04T16:20:45.977 に答える