Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.11/5 (2 votes)
In My Database I Have 10000 Records. In GridView First I Am Showing First 10 Records. In Order To See the Next 10 Records User Need to Click Next Button. But when next button clicks it shows last 10 records so i need to check 10 by 10 records while click next button.

Is There Any Way To Show In ASP.NET GridView ?
Posted
Comments
Maciej Los 8-Oct-14 15:22pm    
What have you done? Where are you stuck?

Here is an idea of cutom pagination on server side:
SQL
--create temporary table
DECLARE @tmp TABLE(ID INT,SomeText NVARCHAR(50))
--add sample data
;WITH InsertionCTE AS
(
	SELECT 1 AS ID, NEWID() AS SomeText
	UNION ALL
	SELECT ID + 2 AS ID, NEWID() AS SomeText
	FROM InsertionCTE 
	WHERE ID<1000
)
INSERT INTO @tmp (ID, SomeText )
SELECT ID, SomeText
FROM InsertionCTE
OPTION (MAXRECURSION 0)

--------------------------------------
--------------------------------------

--an idea of SP begins here:
--------------------------------------
--SP input parameters
DECLARE @startpos INT = 31
DECLARE @countofrecs INT = 10

--body of SP
SELECT RowNo, ID, SomeText
FROM (
	SELECT ID, SomeText, ROW_NUMBER() OVER(ORDER BY ID) AS RowNo
	FROM @tmp
) AS T
WHERE RowNo BETWEEN @startpos AND @startpos + @countofrecs -1


Result:
31	61	B0D1ED50-48BD-4FDF-8EAD-6575FA2957DF
32	63	3CD0B40D-5DDD-48F7-BEAC-8BCFCDB7F037
33	65	9443CDBC-0004-4C7D-A5CB-1B1D30750405
34	67	FEEFC83D-756A-4A99-8DA5-EB95344CDEA8
35	69	7F38B406-98A0-4D4A-8B61-716BF4B0AA6B
36	71	8584DD61-A2C5-4F1A-B56B-7D2AF0F9AF70
37	73	6BBBF847-516A-42E1-9C8A-B7A67A844145
38	75	C45FF16F-6C3C-46DD-849E-5F5DA667D045
39	77	4D6A745E-2ECB-493C-9F81-AF4CCBCFAC3E
40	79	87BD7EA5-12EA-4310-AC3C-D9E3B6C32551


For more samples, please use SearchBox[^].
 
Share this answer
 
there are several way to doing that

you should search for "grid view pagination"

there are several article and question here on codeproject

note that there are 2 way of pagination ,
client side (the query returns 10.000 records and the "gui" 10 at time)
server side (the query returns 10 records and the gui the same)

server side is the best choice to reduce the server load
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900