[英]MVC bind IEnumerable List Of Model
I have a model that contains an ienumerable list of SIte Data I am trying to figure out how to bind it and pull it on a page load and form post 我有一个包含大量SIte数据列表的模型,我试图弄清楚如何绑定它并在页面加载和表单发布时将其拉出
SiteServices is an intersection table to a Servicers table but the relationship is 1 to 1 SiteServices是Servicers表的交集表,但关系是1对1
public Class Site {
public int SiteID {get;set;}
public string Desc {get;set;}
public IList<SiteServices> SiteServices {get;set;}
}
View using 查看使用
@HTML.DropDownListFOr(model =>
model.siteServices,(SelectedList) ViewBag.ServicesList,"Select a Service Area")
try to bind your model on the View and create another variable to hold the selected service 尝试在View上绑定模型并创建另一个变量以保存所选服务
public Class Site {
public int SiteID {get;set;}
public string Desc {get;set;}
public string SiteService {get;set;}
public IList<SiteServices> SiteServices {get;set;}
}
on your View 在您看来
@HTML.DropDownListFOr(model => model.SiteService, Model.SiteServices, "Select a Service Area")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.