Asp.net 多路径值
我正在做一个项目,需要我对列表中的一列进行排序,而列表有几页长。目前,当我排序时,所有内容都正确排序,当我转到下一页时,它就是这样做的。我的问题是,一旦我排序并转到下一页,我就失去了排序值Asp.net 多路径值,asp.net,web-services,asp.net-mvc-2,Asp.net,Web Services,Asp.net Mvc 2,我正在做一个项目,需要我对列表中的一列进行排序,而列表有几页长。目前,当我排序时,所有内容都正确排序,当我转到下一页时,它就是这样做的。我的问题是,一旦我排序并转到下一页,我就失去了排序值 我正在使用ActionLink Html helper方法生成我的页面链接,但是页面链接不包括最后一个链接中的路由值以进行排序。如何使ActionLink使用以前路由中的路由值?解决方案使用HttpContext.Current.Request属性 在标题部分(其中设置了排序),我添加了以下内容: <%
我正在使用ActionLink Html helper方法生成我的页面链接,但是页面链接不包括最后一个链接中的路由值以进行排序。如何使ActionLink使用以前路由中的路由值?解决方案使用HttpContext.Current.Request属性 在标题部分(其中设置了排序),我添加了以下内容:
<%: Html.ActionLink("linkText", "actionName", new { sort = "sortingName", page = HttpContext.Current.Request["page"] })%>
<%: Html.ActionLink(i.ToString(), "actionName", new { page = i, sort = HttpContext.Current.Request["sort"]})
在分页部分,我添加了以下内容:
<%: Html.ActionLink("linkText", "actionName", new { sort = "sortingName", page = HttpContext.Current.Request["page"] })%>
<%: Html.ActionLink(i.ToString(), "actionName", new { page = i, sort = HttpContext.Current.Request["sort"]})
解决方案使用HttpContext.Current.Request属性
在标题部分(其中设置了排序),我添加了以下内容:
<%: Html.ActionLink("linkText", "actionName", new { sort = "sortingName", page = HttpContext.Current.Request["page"] })%>
<%: Html.ActionLink(i.ToString(), "actionName", new { page = i, sort = HttpContext.Current.Request["sort"]})
在分页部分,我添加了以下内容:
<%: Html.ActionLink("linkText", "actionName", new { sort = "sortingName", page = HttpContext.Current.Request["page"] })%>
<%: Html.ActionLink(i.ToString(), "actionName", new { page = i, sort = HttpContext.Current.Request["sort"]})