【发布时间】:2014-01-11 11:34:36
【问题描述】:
如何为多个 DropDownListFor 保存数据?我有此代码,但所选项目没有到达控制器。
我的代码视图:
@Html.DropDownListFor(model => model.Ingredients, new SelectList(Model.ListIngredients, "Id", "Description"), "Select the ingredients", new { multiple = "multiple", })
我的模特:
public ICollection<Ingredient> Ingredients { get; set; }
public ICollection<Ingredient> ListIngredients{ get; set; }
Ingredient.cs:
public string Description { get; set; }
public int Id { get; set; }
我必须更改助手的名称和 ID 才能保存数据?
【问题讨论】:
-
@NikolaMitev 与 ListBoxFor 它仍然对我不起作用并且与 ListBoxFor 无法添加选项标签
标签: html asp.net-mvc-3 asp.net-mvc-4 html-helper html.dropdownlistfor