How to pass Multiple querystrings

Posted by Syedshakeer under ASP.NET category on | Views : 12469
example on how to pass Multiple querystrings in the page..


protected void Button1_Click(object sender, EventArgs e)
string empName = "NET";
string empAddress = "HYD";
string strDate = DateTime.Now.ToShortDateString();
Response.Redirect(string.Format("Page2.aspx?param1={0}&m2={1} &param3={2}", empName , empAddress,strDate));


The on Page2 you can get each values this way below

protected void Page_Load(object sender, EventArgs e)
if ((Request.QueryString["param1"] != null && Request.QueryString["param2"] != null) && Request.QueryString["param3"] != null)
string name = Request.QueryString["param1"];
string address = Request.QueryString["param2"];
string date = Request.QueryString["param3"];


Comments or Responses

Posted by: Neeks on: 3/8/2009 Level:Bronze | Status: [Member]
You cannot assign the Multiple parameters directly.
You have to join them with '&' (amp).

Response.Redirect(string.Format("~/Default.aspx?param1={0}&Param2={1}&Param3={2}", "Nikhil", "B", "Chauhan"));

Login to post response