Search code examples
c#asp.net-mvcasp.net-mvc-4dropdownlistfor

asp.net mvc dropdownlist with sample date


I am trying to mock a dropdownlist with no data and just "select" text. How to do that?

I tried this

@Html.DropDownList("",new List<SelectListItem>(),"Select")

I know it should be some thing similar to

 @Html.DropDownListFor(x => x.SelectedValue, Model.sampleList, "Select")

but I am not interacting with controller as I am UI designer. How can I change my code?


Solution

  • You have it correct. However, you need to provide the name of the field:

    @Html.DropDownList("NameOfField", new List<SelectListItem>(), "Select")