Pagination in asp.net

I heard that in the .NET framework ASP.NET allows easy pagination just by adding attributes within the datagrid view template (or something similar).

My problem is, is how this is done behind the scenes?
Because my problem is that with dealing with a lot of records, does asp.net bring back all records then divides the records in to how many records you set it to show or does it bring back a batch each time? thus querying the database on every page with a set amount of records to bring back on each query?

i want to display records in an admin system but I do not want to bring back all records in one go, hopefully this will be less strenious on the server.

Each time you page between records, the entire record is retrieved from the database. If you’ll be dealing with lots of records then you will have to write custom sql statement to handle your custom paging.

You may consider using linq to sql which will make life easier for you :slight_smile:

you can read this article, this might help you out… http://www.c-sharpcorner.com/UploadFile/amit_agrl/PagingInASPNet11262005011702AM/PagingInASPNet.aspx

for pagination best approach is using custom sql(stored procedure).

I would suggest you to go with custom paging… the easiest way is to define the page size and then play with records using that defined size and page number using SQL and retrive only needed data and bind it to grid, i think that is the fastest way and least load on server as well as DB.