我需要输入这个值:
@Html.DropDownList("region", new[]{
new SelectListItem() { Text = "MA", Value = "MA" },
new SelectListItem() { Text = "BC", Value = "BC" },
new SelectListItem() { Text = "ON", Value = "ON" },
})
进入这里:
@Html.ActionLink("<<", "List", new { page = 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter, zipCode = ViewData["zipCode"], searchType = ViewData["searchType"], distance = ViewData["distance"], region = ViewData["region"], country = ViewData["country"] })
ViewData["region"] 为空,单击链接时无法获取该值。如何将 DropDownList 的区域值放入查询字符串?我在代码中将区域设置为默认值 MA:
public ViewResult List(string sortOrder, string currentFilter, string searchString, int? page, string zipCode, string region, int? distance, string searchType, string country)
{
_storeService = new StoreService();
//sets defaults
if (String.IsNullOrEmpty(zipCode))
{
zipCode = "02472";
}
if (String.IsNullOrEmpty(region))
{
region = "MA";
}
}