Harpreet Singh
Harpreet Singh

Reputation: 13

How to pass multiple parameters using Querystring in asp.net?

protected void btnBack_Click(object sender, EventArgs e)
{
    if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);
        if (custTotle == 0)
        {
            Response.Redirect(prevPage);
        }
        else
        {
            Response.Redirect("~/Pages/Product.aspx?id=" + id + "Customize=" + custTotle);
        }
    }

}

In this I want to pass two different values to the page but it is not redirecting and I get the error

"Input string was not in a correct format."

at id = Convert.ToInt32(Request.QueryString["id"]);

Any suggestion?

Upvotes: 1

Views: 9396

Answers (2)

Bhuban Shrestha
Bhuban Shrestha

Reputation: 1324

You have to separate query string key by & character

Response.Redirect("~/Pages/Product.aspx?id=" + id + "&Customize=" + custTotle);

Upvotes: 2

Raz Zelinger
Raz Zelinger

Reputation: 696

I guess your missing a "&" in the url:

Response.Redirect("~/Pages/Product.aspx?id=" + id + "&Customize=" + custTotle);

Upvotes: 1

Related Questions