我有下拉列表:
@Html.DropDownListFor(m => m.Register.SelectCompany, Model.Register.Company, "Please select")
我有模特:
[Required(ErrorMessage = "*")]
[Display(Name = "Company name")]
public int SelecCompanyId{ get; set; }
public System.Web.Mvc.SelectList CompanyName{ get; set; }
当我尝试这样做时:
companyAccount.Company = (ICompany)Company.Find(model.Register.SelectCompanyId);
我收到错误
具有键' Register.SelectCompanyId'的ViewData项。是的 输入' System.Int32'但必须是类型 ' IEnumerable的'"}
我的课程也是:
public class Company: ICompany
{
public int Id { get; set; }
public string CompanyName { get; set; }
}