views:

1170

answers:

2

I've got a Gridview that's populated by a Search button and I'm not sure how to go about doing custom paging for it. I run the search query using sp_executeSQL right now and it returns the entire resultset.

I'd like to know what steps I should take to set up custom paging and sorting on the GridView and the most efficient way to modify a procedure that uses Sp_ExecuteSQL to generate a result that's a single page. I've seen methods that use a temporary table, etc.

Once I have the proc written, how do I set up the events in the page?

+1  A: 

asp:gridview comes with a paging setup if you didn't know that has sorting and paging with a certain number of fields techniques that are found http://www.dotnetspider.com/resources/1249-Grid-View-Paging-Sorting.aspx

But if you want to come up with your own paging technique which sounds like paging or sorting in the Database then this is different from paging in memory, which is what the asp:gridview webcontrol does. So if you want to page and sort from DB then you should create a stored procedure that does this and when it comes to your search button call that procedure which will take in your specific paramters(page number, how many entries per page,etc..)

This site http://aspnet.4guysfromrolla.com/articles/031506-1.aspx goes much in detail on how better paging and sorting is if down from the DB

TStamper
I have found custom paging to perform much better then the default asp.net paging - the 4guysfromrolla article covers it pretty well.
brendan
A: 

you may want to look this question to get the real use of the approaches.

http://stackoverflow.com/questions/1061574/custom-paging-or-standard-paging-in-asp-net-which-method-is-efficient

sahridhayan