C# ModelState对空Html.DropDownList无效

C# ModelState对空Html.DropDownList无效,c#,entity-framework,asp.net-mvc-4,C#,Entity Framework,Asp.net Mvc 4,我有一个带有下拉列表的表单,其中有一个空白选择。我希望用户能够输入一个空白的选择,如果他们愿意。但是,模型状态对于CountryID无效。任何帮助都将不胜感激 Create.cshtml: @(Html.DropDownList("CountryID", Model.Countries, "")) Office.cs: public class Office { public Office() { } public Office(Int32 SyncID, s

我有一个带有下拉列表的表单,其中有一个空白选择。我希望用户能够输入一个空白的选择,如果他们愿意。但是,模型状态对于CountryID无效。任何帮助都将不胜感激

Create.cshtml:

@(Html.DropDownList("CountryID", Model.Countries, ""))
Office.cs:

public class Office
{
    public Office()
    {
    }

    public Office(Int32 SyncID, string OfficeName)
    {
        this.SyncID = SyncID;
        this.OfficeName = OfficeName;
    }

    public Int32 OfficeID { get; set; }
    public Int32 SyncID { get; set; }
    public Int32 OfficeRollupID { get; set; }
    public Int32 StateProvID { get; set; }
    public Int32 CountryID { get; set; }
    public bool Active { get; set; }

    [Required]
    [Display(Name="Office Name")]
    public string OfficeName { get; set; }

    [Display(Name = "Office Rollup")]
    public IEnumerable<SelectListItem> OfficeRollups { get; set; }

    [Display(Name = "State/Province")]
    public IEnumerable<SelectListItem> StateProvinces { get; set; }

    [Display(Name = "Country")]
    public IEnumerable<SelectListItem> Countries { get; set; }

    public List<SquareFootage> SquareFootages { get; set; }
}

使countryId为空

public int? CountryID { get; set; }

CountryID
属性在哪里?您的办公模型中只有一个属性?我添加了CountryID属性,谢谢您的评论。这是您的整个模型类吗?上面没有其他带有验证注释的属性?我添加了整个Office类。
public int? CountryID { get; set; }