【问题标题】:html helper dropdown list to display hardcoded values in my view, not values from databasehtml helper 下拉列表以在我的视图中显示硬编码值,而不是数据库中的值
【发布时间】:2011-09-02 05:16:31
【问题描述】:

我希望能够显示一个下拉列表,其中的值不是来自我的数据库,但具有硬编码的值,这些值将用于稍后执行插入查询。我该怎么做呢?

<%=Html.DropDownList("Chart Type", "Horizontal") %>

我需要将值水平、垂直、派放在下拉列表中。

非常感谢任何帮助!

【问题讨论】:

    标签: html asp.net-mvc model-view-controller


    【解决方案1】:

    试试

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

    【讨论】:

      猜你喜欢
      • 2017-12-06
      • 1970-01-01
      • 2012-05-21
      • 1970-01-01
      • 2021-08-02
      • 2018-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多