What Html Helper Do I Use To Create A Simple Dropdownlist That Doesn't Take In Any Variables?
I want to have a simple select->option dropdown list that I am not passing any (SelectItem collection) values to. I already know the values so I don't need to do all that (they
Solution 1:
Use a select list with either a List of strings or a Dictionary of items (if you want different id's and values) inside your drop down list to define your values.
<%= Html.DropDownList("day", new SelectList(
new Dictionary<int,string> { { 1, "Sunday" }, { 2, "Monday" } },
"Key", "Value"))
%>
<%= Html.DropDownList("hour", new SelectList(
new List<string>() { "1", "2", "3", "4" }))
%>
Solution 2:
If they are static keep them as HTML. No sense complicating things.
Post a Comment for "What Html Helper Do I Use To Create A Simple Dropdownlist That Doesn't Take In Any Variables?"