They seem to be so nasty.
I have a gridview, and the query it runs pulls back 10,000 results if no filters are set… and displays 10 of them on the first page. You press page 2, and then it does the query again… and again…
Isn’t there a way to cache them? Isn’t there a much easier way to bring in all the results then filter them live without repeated queries? Must ASP.NET be all about a struggle against the gridview?
I would love to know if there is a better way…
If you’re using SQL Server 2005 and above, you can make use of the
ROW_NUMBER()function in your query, which you can use to page the rows returned at source.ScottGu has a detailed blog post here using a DataList, but this is equally applicable to GridViews
This blog entry has a more concise introduction to the specifics of
ROW_NUMBER()