Paging in an ASP Web Page?

I'm new to this, so forgive me if this is trivial. Anyway, I am creating a simple ASP web page that reports data from a table in a database that has 5 elements. I use GridView to display data, and it works fine, but I would like to limit the results to three elements so that I can enable paging. I tried setting the select statement from something like "select * from country" to

select * from country limit 3

but I get the message "There was an error message executing the request" when I try to test it. Is there any other way I have to do this?

+3
source share
4 answers

set the gridview property PageSize=3

+1
source

TOP, SQL Server:

SELECT TOP 3 * FROM COUNTRY;
+1

SQL Server top

select top 3 * from country
+1

Depending on the total number of records that you expect to have in the country table, a simple solution would be to use asp:DataPagerwithout any restrictions on the number of rows returned from SQL.

This will handle the entire paging for you, however, the full data set is saved in the page view state, and therefore this is not a suitable solution, you expect 1000 records.

+1
source

All Articles