Asp.net mvc @Html.DropDownListFor不包含的定义

Asp.net mvc @Html.DropDownListFor不包含的定义,asp.net-mvc,Asp.net Mvc,不知道我错过了什么。我正试图显示一个下拉列表,其中包含我所在国家/地区表中的记录 我的型号 public ClientSMSAccountCustom() { this.Countries = new List<SelectListItem>(); } public IList<SelectListItem> Countries { get; set; } 我的观点 @Html.DropDownListFor(model => model.Cou

不知道我错过了什么。我正试图显示一个下拉列表,其中包含我所在国家/地区表中的记录

我的型号

public ClientSMSAccountCustom()
{
    this.Countries = new List<SelectListItem>();
}     
public IList<SelectListItem> Countries { get; set; }
我的观点

@Html.DropDownListFor(model => model.CountryID, Model.Countries)
这就是确切的错误

//get all countries
var countries = rad.Countries.OrderBy(x => x.CountryID).ToList();

foreach (var c in countries)
{
    SelectListItem item = new SelectListItem();
    item.Text = c.Description;
    item.Value = c.CountryID.ToString();
    model.Countries.Add(item);
}
“TotalDesk.Models.ClientsMSCountCustom”不包含“CountryID”的定义,并且找不到接受类型为“TotalDesk.Models.ClientsMSCountCustom”的第一个参数的扩展方法“CountryID”(是否缺少using指令或程序集引用?)


TotalDesk.Models.clientsMSCountCustom
是模型类

结果发现我的模型类中缺少属性concountyID

谢谢斯蒂芬

    public ClientSMSAccountCustom()
    {
        this.Countries = new List<SelectListItem>();
    }

    public int CountryID { get; set; }
    public IList<SelectListItem> Countries { get; set; }
公共客户端mssaccountcustom()
{
this.Countries=新列表();
}
public int CountryID{get;set;}
公共IList国家{get;set;}

错误消息是不言自明的。您的
ClientSMSAccountCustom
模型不包含名为
CountryID
的属性@StephenMuecke我错过了什么?如何让它读取Countries属性?将
public int CountryID{get;set;}
属性添加到
ClientSMSAccountCustom
模型中。@StephenMuecke有效。非常感谢。