Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 help is much appreciated!

like image 743
Hriskesh Ashokan Avatar asked Nov 20 '25 08:11

Hriskesh Ashokan


1 Answers

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" }
                     }) %>
like image 79
Bala R Avatar answered Nov 21 '25 22:11

Bala R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!