【发布时间】:2012-03-26 12:23:52
【问题描述】:
i 在 DropDownList 中显示一个数据:(im ussign datacontext)
控制器:
var query = newdb.Incident.Select(c => new { c.ID, c.Name }); ViewBag.items = new SelectList(query.AsEnumerable(), "ID", "Name");
查看:
@Html.DropDownList("items", (SelectList) ViewBag.items, "--Select a Incident--")
问题:
我想知道如何从 DropDownlist 中选择一个项目并将参数发送回所选项目的控制器,因为我尝试了这个并且不起作用:
@using (Html.BeginForm("er", "er", FormMethod.Post, new { id = 4 })){
@Html.DropDownList("items", (SelectList) ViewBag.items, "--Select a Incident--")}
希望有人能帮忙笑
【问题讨论】:
-
查看我的教程 [使用 DropDownList 框和 jQuery][1] 和 [我的博客 Cascading DropDownList in ASP.Net MVC][2] [1]: asp.net/mvc/tutorials/javascript/… [2]: @ 987654322@
标签: asp.net-mvc