我有一个表单,它被发送到一个强类型视图的控制器。视图的类型是"shitModel",它有一个"shitType"列表
模型:
public class shitModel {
public string name;
public List<shitType> types;
}
视图:
should contain listboxfor model.types
任何想法?由于
如果是razor视图,请在视图上编写以下代码
@*i am considering you have Name and ID members in your shitType class*@
@Html.DropDownList("shitTypes", Model.types.Select(t=> new SelectListItem{ Text = t.Name, Value = t.ID}))