Search code examples
c#asp.nethtml.beginform

How to prepopulate drop down box with default custom value Html.DropDownListFor(...)


So I have a prefilled drop down list

@Html.DropDownListFor(a => a.Item2.CategoryName, new SelectList(Model.Item1.Categories))

I want to add a default selection "All Categories" in the drop down list, how can I accomplish that?


Solution

  • try this

    @Html.DropDownListFor(a => a.Item2.CategoryName, new SelectList(Model.Item1.Categories),"All Categories")