I have a routing rule
routes.MapRoute(
"Search", // Route name
"Restaurant/AdvancedSearch/{foodType}", // URL with parameters
new { controller = "Restaurant", action = "AdvancedSearch", foodType = "" } // Parameter defaults
);
In my view I want to pass through value from a select list into the 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>
<% } %>
Within my controller the foodType value is always null, not the item id of the selected value?
public ActionResult AdvancedSearch(int? foodType)
{
return View();
}