c# - MVC Razor Form DropDownListFor objects -
i have dropdown list defined follows:
@html.dropdownlistfor(model => model.properties, new selectlist(model.properties, "propertyid", "propertyname"))
when submit form, model has null in properties
field. doing wrong? dropdown list incorrectly defined?
it's not clear type properties
object, looking @ name guess kind of collection.
usually dropdownlist has 1 value. should have in model:
public int propertyid { get; set; }
and in view:
@html.dropdownlistfor(model => model.propertyid , new selectlist(model.properties, "propertyid", "propertyname"))
so when post occurs can selected item property.
Comments
Post a Comment