html助手下拉列表,用于在我的视图中显示硬编码的值,而不是数据库中的值
我希望能够显示一个dropdownlist,它的值不是来自我的数据库,而是硬编码的值,这些值将用于以后执行插入查询。我该怎么做呢html助手下拉列表,用于在我的视图中显示硬编码的值,而不是数据库中的值,html,asp.net-mvc,model-view-controller,Html,Asp.net Mvc,Model View Controller,我希望能够显示一个dropdownlist,它的值不是来自我的数据库,而是硬编码的值,这些值将用于以后执行插入查询。我该怎么做呢 <%=Html.DropDownList("Chart Type", "Horizontal") %> 我需要在dropdownlist中显示水平、垂直和饼图的值 非常感谢您的帮助 试试看 <%=Html.DropDownList("Chart Type", new List<SelectListItem>
<%=Html.DropDownList("Chart Type", "Horizontal") %>
我需要在dropdownlist中显示水平、垂直和饼图的值
非常感谢您的帮助 试试看
<%=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" }
}) %>