I am rendering a dropdown list.
ViewBag.Categories = new SelectList(db.HelpCategories, "ID", "Name");
In my view I call it like this:
Categories: @Html.DropDownList("Categories", (SelectList)ViewBag.Categories, "All")
For which I get select values like this.
<select id="Categories" name="Categories">
<option value="">All</option>
<option value="1">Dėl Krepšelių</option>
</select>
I really need to set the value of "All" to 0. Can't figure out a way to do it. Found a tutorial that it's done with SelectListItem, but that doesn't fit my code. Any help is really appreciated, thank you.
0? And if you do want it then you must generate anIEnumerable<SelectListItem>that incluse one withValue="0"andText="All"(and delete the 3rd parameter in yourDropDownList()method) - user3559349