Click here to Skip to main content
14,735,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am passing selected rows of gridview (in Page1.aspx)to Textboxes Of Page2.aspx.I am retrieving values of selected rows in pageload event of Page2.aspx .Now I have button CHANGE in Page2.aspx.On clicking Button CHANGE, a new page (Page3.aspx) is opened .I am using javascript function to open PopUp window.I am not sending any information from page2.aspx to page3.aspx.
Now in Page3.aspx,I have some filters based on which data in grid is loaded and selected rows of grid is now transfered to page2.aspx using session variables.
Problem is when I click Button to open Page3.aspx, then Page2 is refreshed again and it throws an exception Index Out Of Exception in request.querystring.
how to solve this problem???
Updated 26-Jun-10 0:33am

1 solution

Clicking the button "Change" in Page2.aspx does a postback. At this time NO QueryString is passed. The following methods will solve your issue:

1) I think you are iterating through QuesryString collection. Do a check for null before doing that.
2) Write JavaScript (to open the popup window) on OnClientClick of the button. The last line of the function would be return false;
function openPopup()
  return false;

And call this function this way:
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return openPopup()" />

Hope this helps!
akkanshagupta 26-Jun-10 6:25am
I tried this but got the same problem again.As son as i click button CHANGE to open Page3.aspx, it opens but when any postback occurs in page3.aspx,it will refresh the page2.aspx.Hence causing same exception for querystring.please tell me another option.
Ankur\m/ 26-Jun-10 7:10am
akkanshagupta wrote: "but when any postback occurs in page3.aspx,it will refresh the page2.aspx."
Anyways, try the 1st option then i.e check the QueryString for null values before using it.
Something like:
if(Request.QueryString[i] != null)
//get values from querystring.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900