I have a page for searching and the search result will be shown in gridview control. I have a button called Clear to clear out the search result in gridview and also the text box where user enter the search criteria.

At first, i did the Clearing by doing page refresh print("Response.Redirect(~/blah/search.aspx");but i'm not sure if that's the best way to clear a page. Would it be better to set the text box to string empty and set the gridview datasource to Nothing then bind it?

No correct solution


I prefer the redirect method for several reason:

  1. Use can hit back and get their data back.
  2. Less code to maintain an remember about when you change the page. (If you add a new field will you remember to clear that also?)

I would rather clear the text box and bind the gridview to a empty list.

The best way to do this is not do it at all.

Try to design the search box/button so that it is obvious that you can initiate a new search just by typing in the text box and clicking the search button. Take a cue from google. It is likely that most of your users are familiar with this behavior already.

If starting from scratch rather than refining the current search is the most common behavior of a user, then you could use some javascript to clear the search box on focus. Or less intrusively, you could just select the text on focus to enable type-over style clearing.


There shouldn't be any reason to waste your server's cpu/bandwidth, or your user's time just to search from a blank page.

I usually just make a link that says "New Search" (since you are starting over, and not just clearing the form, which is what "Clear" would imply to me) that points to the search page instead of a submit button to avoid an unnecessary postback just to redirect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow