我正在尝试提供一个链接来过滤搜索结果。
<%= Html.ActionLink("Filter Results", "Index", new { page = Model.RestaurantList.PageIndex(), searchText = Model.SearchText, useFilter = true, filterOption = Model.FilterOption, filterText = Model.FilterText }, null)%>控制器的定义是这样的
public ActionResult Index(int? page, string searchText, bool useFilter, string filterText, string filterOption)但是,当我调试它时,这些值没有正确设置,甚至useFilter变量也没有正确设置。
我的链接呈现为localhost/home/index/true?page=0
有什么办法解决这个问题吗?
发布于 2009-06-28 04:55:49
代码段看起来很好。我认为有两个可能的错误:
如果你仍然不能工作,你可能需要发布更多的信息(比如路由映射代码,视图/控制器的名称)
发布于 2009-06-28 02:18:44
看起来应该行得通。
您是否验证了要传递给ActionLink的模型字段确实包含数据?
发布于 2009-06-28 18:52:42
然而,当我调试它时,这些值没有正确设置,甚至useFilter变量也没有正确设置。我的链接呈现为localhost/home/index/true?page=0
我认为您的useFilter参数实际上是呈现的。我猜是映射到路线上的。
尝试为searchText设置硬编码值
如果它显示,那么您没有在控制器中设置您的模型。
https://stackoverflow.com/questions/1054055
复制相似问题