Saving search state.

wavemasta

Member
Joined
Feb 12, 2009
Messages
12
Programming Experience
10+
Dear All:

I have a gridview with multiple columns. Each of those columns has a search text box above it. When a search is done, the page does a database query and then refills the grid, which works fine.
The problem is that when people leave the page, and come back, they want to see the last (Search state) of the page, with the results of the previous search in the grid.

I have tried to implement this with sessions and view states but I haven't been able to get it to work well. I try to save the text in the textbox in a viewstate or session, (in the textchanged event) and then pull it out when the page loads...but that hasn't worked either.
Any ideas would be appreciated!

Regards
 
how about using a query string to store each search value and then storing the whole query string in a session. Then when a user comes back to the search page, just check to see if the Session is not nothing and apply the filter.
 
r3plica:
Thanks for the reply. Lemme break down my algorithm for you.

1) page loads

2) if page is not postback then check session variables for previously stored search parameters.

3)if those session variables exist, then stuff their values inside variables.

4) use those variables to query the stored procedure.

5) if step 3 is false, then get the variable values from the text boxes or drop down lists on the page, and use them to run the stored procedure.

Now the issue is this:

What if I do a new search, with different parameters? Assuming I did a previous search, those session variables will exist with the old values, and will not allow me to do a new search....I guess Ive hit a snag in my thinking....

Please help. :D
 
Back
Top