鉴于我有一个模型对象像...MVC 3,单选按钮和模型
public class MyModel
{
public int SomeProperty { get; set; }
public int SomeOtherProperty { get; set; }
public IList<DeliveryDetail> DeliveryDetails { get; set; }
}
public DeliveryDetail
{
public string Description { get; set; }
public bool IsSelected { get; set; }
}
,我通过它通过对这样的观...
// Controller
public ActionResult Index()
{
MyModel myModel = Factory.CreateModelWithDeliveryDetails(x);
return View(myModel);
}
我会怎样呈现/绑定一组单选按钮(在视图中)?使用下面的代码不会发布数据传回:
@foreach(var deliveryDetail in @Model.DeliveryDetails)
{
@deliveryDetail.Description
@Html.RadioButtonFor(x => deliveryDetail, false)
}