Reputation: 993
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
SiteServices is an intersection table to a Servicers table but the relationship is 1 to 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")
Upvotes: 0
Views: 745
Reputation: 161
try to bind your model on the View and create another variable to hold the selected service
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")
Upvotes: 1