I have the following enum:

public enum EmploymentType
{
  FullTime,
  PartTime,
  Contract
}

public class MyViewModel
{
   public string searchTerm { get; set; }
   public EmploymentType EmploymentType { get; set; }
}

 public ActionResult Index(string searchTerm, string EmploymentType)
{
     // some other stuff

     var viewModel = new MyViewModel {  SearchTerm = search };

     return View(viewModel);      
}

@Html.EnumDropDownListFor(m => m.EmploymentType, "", new { @class = "form-control" })

When I load the page the dropdown default to the first item FullTime instead of the empty option. I am not setting the default value in my controller so why does it default to the first item and how can i get it to default to the empty option value instead?

Related posts

Recent Viewed