Last post Sep 06, 2005 04:15 PM by mru22
Sep 06, 2005 05:57 AM|Speerman|LINK
SELECT * FROM (
SELECT TOP "+dgResults.PageSize.ToString()+" id, name FROM(
SELECT TOP "+((dgResults.PageSize)*(iPage+1)).ToString()+" FROM
ORDER BY name ASC
) AS newtbl ORDER BY name DESC
) AS newtbl2 ORDER BY name ASC
When having 16 results and a pagesize of 7, I want 7 results on the first page, 7 results on the second page and 2 results on the third page.
Thanks in advance!
Sep 06, 2005 04:15 PM|mru22|LINK
Since you are limiting records, what is the potential number that could be returned. I see some developers try to limit 100 records to 10 but generally you won't notice a performance difference so its often easier to bring them all over to the grid and
let the datagrid determine if the next and previous page buttons are displayed (much easier IMO).
If it can be a lot of records and reducing the results is necessary you could make a temp table and do paging in the database, (I do not like that solution very much it was popular with classic asp), or you can use custom paging on the datagrid and filter
the records there.
Another possible solution is doing a select not in such as
Where iPage starts at Zero
select top dgresults.Pagesize * from ...
where ...Id not in
(Select top dgresults.Pagesize * ipage ...Id from .....)