html helper dropdown list to display hardcoded values in my view, not values from database
I want to be able to display a dropdownlist that has values not from my database, but have hardcoded values that will be used to perform an insert query later. How would I go about doing it?
<%=Html.DropDownList("Chart Type", "Horizontal") %>
I need values Horizontal, Vertical, Pie to be in the dropdownlist.
Any hel开发者_如何学编程p is much appreciated!
Try
<%=Html.DropDownList("Chart Type", new List<SelectListItem>
{
new SelectListItem{ Text="Horizontal", Value = "Horizontal" },
new SelectListItem{ Text="Vertical", Value = "Vertical" },
new SelectListItem{ Text="Pie", Value = "Pie" }
}) %>
精彩评论