开发者

html helper dropdown list to display hardcoded values in my view, not values from database

开发者 https://www.devze.com 2023-03-08 21:03 出处:网络
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?

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号