I have a function that retrieves data from database and add it into list. My list is ready and shows the data but i want paging on that list so that it shows limited records
You can page a list with LINQ, like this:
IList GetPage(IList list, int page, int pageSize) {
return list.Skip(page*pageSize).Take(pageSize).ToList();
}
For example, suppose each page has 50 records. To get a third page, call
IList thirdPage = GetPage(dataList, 3, 50);
Note, however, that applying paging to data in memory makes very little sense: the idea behind paging is to cut down on the time it takes to retrieve your data from the database, and to save some memory by keeping only a single page, which is not going to happen in your case, because all data is retrieved at once.
In order to make paging worth the effort, you need to move it into the database. Change your method to accept page size and number, and use them to change the SQL to retrieve the list for a single page. Don't forget to force ordering on your sql read, otherwise the same data might appear on different pages. Your SQL needs to be modified to support pagination. This is done differently depending on your database. MS SQL Server solution is described in this answer.