2015-11-07 66 views
0

我有三個表格正在這個表格上進行組合。下拉列表是爲了在我們的數據庫中顯示所有可能的品牌名稱並返回該品牌的UID。我已經嘗試了許多不同的方法來解決這個問題,但無濟於事。目前,我收到一條錯誤消息:'不能將lambda表達式轉換爲字符串類型,因爲它不是委託類型。「所以我必須使用DropDownList助手錯誤。ASP.NET MVC 5:如何使用ViewModel中的IEnumumerble添加下拉列表?

這裏是我的ViewModel:

public class AlternateCodeViewModel 
{ 
    //public web2_item_alternate_code web2_item_alternate_code { get; set; } 

    [Key] 
    [Column(Order = 0)] 
    public int inv_mast_uid { get; set; } 

    [Key] 
    [Column(Order = 1)] 
    [StringLength(50)] 
    [Display(Name = "Alternate Code")] 
    public string Alternate_Code_Item_ID { get; set; } 

    [Key] 
    [Column(Order = 2)] 
    public int Alternate_Code_Brand_ID { get; set; } 

    [Required] 
    [StringLength(1)] 
    [Display(Name = "Exact Flag")] 
    public string Exact_Flag { get; set; } 

    [Required] 
    [StringLength(1)] 
    [Display(Name = "Delete Flag")] 
    public string Delete_Flag { get; set; } 

    public int item_brand_uid { get; set; } 

    public IEnumerable<web2_item_brands> web2_item_brands { get; set; } 
    public inv_mast inv_mast { get; set; } 


}` 

這裏是我的控制器:

這是我的觀點:

<div class="form-group"> 
     @Html.LabelFor(model => model.web2_item_brands, "Brand Name", htmlAttributes: new { @class = "control-label col-md-2" }) 
     <div class="col-md-10"> 
      @Html.DropDownListFor(model => model.web2_item_brands, Model.web2_item_brands, htmlAttributes: new { @class = "form-control" }) 
      @*@Html.ValidationMessageFor(model => model.web2_item_brands, "", new { @class = "text-danger" })*@ 
     </div> 
    </div> 
+1

您不能將一個'