Page indexing in c#
-
Dear All, I am working on grid view i wana to assign paging index as like in google page with a constant range like 1 to 25. Can any one guide me what i have to do for this Please do replay..
-
Dear All, I am working on grid view i wana to assign paging index as like in google page with a constant range like 1 to 25. Can any one guide me what i have to do for this Please do replay..
well you could load all your rows into a datatable or something, then you create a bunch of buttons to act as page numbers, or a drop down list, based on the number of rows in the datatable. So if you have 128 rows you could do...
int numberOfPages = numRows % 25 == 0 ? numRows / 25 : numRows / 25 + 1;
then on each button click, you load the first 25 result starting at a number obtained by...
int startRowNumber = (pageNumber - 1) * 25;
Alternatively you can get the startRowNumber and search you datasource for each page load. Depending on what your data source is will depend how you could do this. Some databases have functionality to specify a results count and start value. But you will have to look into that yourself
Life goes very fast. Tomorrow, today is already yesterday.