【发布时间】:2010-12-09 18:23:12
【问题描述】:
我有一个路由规则
routes.MapRoute(
"Search", // Route name
"Restaurant/AdvancedSearch/{foodType}", // URL with parameters
new { controller = "Restaurant", action = "AdvancedSearch", foodType = "" } // Parameter defaults
);
在我看来,我想将值从选择列表传递到 routeLink
<% using (Html.BeginForm("SimpleSearch", "Restaurant")) { %>
<div>
<fieldset>
<legend>Restaurant Search</legend>
<label for="Food">Type of food:</label>
<%= Html.DropDownList("Food", Model.FoodType, "-- Select --")%>
<%= Html.RouteLink("Advanced search?", "Search", new { foodType=(ViewData["Food"]) })%>
</fieldset>
</div>
<% } %>
在我的控制器中,foodType 值始终为 null,而不是所选值的项目 id?
public ActionResult AdvancedSearch(int? foodType)
{
return View();
}
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-routing