我有这种情况:
public class Manager {
public int DefaultDistributorId { get; set; }
public List<Distributor> Distributors { get; set; }
}
public class Distributor {
public int DistributorId { get; set; }
public string DistributorName { get; set; }
}
我想根据上面集合中的每个分发者创建一个单选按钮列表。当我选择某个分销商时,我想将该DefaultDistributorId
属性填充到 Manager 实体中。我怎样才能做到这一点?
@for (int count = 0; count < Model.Distributors.Count; ++count) {
@Html.RadioButtonFor(m => m.DefaultDistributorId,
Model.Distributors[count].DistributorId);
}
有任何想法吗?