Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
html助手下拉列表,用于在我的视图中显示硬编码的值,而不是数据库中的值_Html_Asp.net Mvc_Model View Controller - Fatal编程技术网

html助手下拉列表,用于在我的视图中显示硬编码的值,而不是数据库中的值

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>

我希望能够显示一个dropdownlist,它的值不是来自我的数据库,而是硬编码的值,这些值将用于以后执行插入查询。我该怎么做呢

<%=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" }
                     }) %>