简体   繁体   English

Response.Redirect 与查询字符串

[英]Response.Redirect with querystring

This is a simple question but I was wondering how to do this.这是一个简单的问题,但我想知道如何做到这一点。 I have a gridview that has a list of customers and in the gridview there is a linkbutton as a template field that says view cart.我有一个 gridview 有一个客户列表,在 gridview 中有一个链接按钮作为模板字段,显示查看购物车。 In the onclick method I have在 onclick 方法中我有

Response.Redirect("~/Cart.aspx?ID=" + Request.QueryString["ID"]);

On the cart aspx page I have another gridview that I want it to display just the items in that customers specific cart.在购物车 aspx 页面上,我有另一个 gridview,我希望它只显示该客户特定购物车中的项目。 This gridview has a querystring parameter这个 gridview 有一个查询字符串参数

            <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="String" />
        </SelectParameters>

However rightnow, nothing is showing up in the gridview for the cart.但是现在,购物车的 gridview 中没有显示任何内容。 How can I achieve my goal?我怎样才能实现我的目标?

 var routeValuesDictionary = new RouteValueDictionary();
foreach (var key in Request.QueryString.AllKeys)
{
    routeValuesDictionary.Add(key, Request.QueryString[key]);
}
return RedirectToAction("ActionName", "Controller", new RouteValueDictionary(routeValuesDictionary));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM