如何爲多個DropDownListFor保存數據?我有這個代碼,但選定的項目沒有到達控制器。保存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用於保存數據?
這可能有助於http://stackoverflow.com/a/8434800/1126404 –
@NikolaMitev與ListBoxFor它仍然不工作,我和一個ListBoxFor不可能添加一個選項標籤 – Ninita