【问题标题】:ASP.Net-MVC sample code to retrieve selected item from html dropdownlistASP.Net-MVC 示例代码从 html 下拉列表中检索所选项目
【发布时间】:2009-05-26 05:36:06
【问题描述】:

谁能给我一个示例代码来从 html.dropdownlist 中检索项目?

【问题讨论】:

标签: asp.net-mvc


【解决方案1】:

假设您在视图中有这个 DropDown:

<p><label for="ProductType">Product Type:</label>
<br /><%=Html.DropDownList("ProductTypeDropDown", 
             New SelectList(ViewData("ProductTypes"), 
             "ProductTypeID", "Name"))%>
</p>

您可以使用

简单地检索控制器中的选定值
Product.ProductType = form("ProductTypeDropDown")

【讨论】:

  • 我很抱歉不清楚。无论如何,我希望代码在控制器端检索。
  • 嗯...我已经发布了视图和控制端以防万一。您解决了问题还是需要进一步的帮助?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-17
  • 1970-01-01
  • 1970-01-01
  • 2018-03-01
  • 1970-01-01
相关资源
最近更新 更多