Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello. I`m making board with ASP.NET GridView.

I made stored procedure about showing to GridViwe(contents of board) and Custom paging to Repeater.

And I tried to show text search result, It works, but quite different what I want.

The first page of the result page, it's okay, but when I clicked page button,

all page is showing in GridView...I don`t know how to fix it

Here is my Stored prodecure(MSSQL) and the Custom Paging example link(I made my custom paging

like that)

Please somebody help me.

Custom Paging in ASP.NET GridView <- This is Link

What I have tried:

CREATE PROCEDURE TestCustomPagingAfterSearch
@BoardID int --FK(PK in tb_BoardMaster, I have 3 Boards)
, @PageIndex int
, @PageSize int
, @RecordCount int output
, @SearchText nvarchar(50)
AS
BEGIN
SET NOCOUNT ON;

;with cte as (
SELECT
ROW_NUMBER() OVER (ORDER BY I.BoardNotice desc, I.BoardItemID desc) AS indexNO
, I.BoardItemID -- PK
, I.BoardTitle
, I.UserName
, I.BoardRegDate
, I.BoardHit
, I.BoardNotice -- To verify notice or not(default value is N(not notice))
, (SELECT COUNT(FileID) FROM tb_AttachedFiles A WHERE A.BoardItemID = I.BoardItemID) AS FileCount
FROM tb_BoardItem I
WHERE BoardID = @BoardID
AND
BoardTitle like @SearchText
OR
UserName like @SearchText
OR
BoardContents like @SearchText
)


SELECT * FROM cte
WHERE
indexNO BETWEEN (@PageIndex -1) * @PageSize +1 AND (((@PageIndex -1) * @PageSize +1) + @PageSize) -1
--ORDER BY
--BoardNotice DESC
SET @RecordCount = (
SELECT COUNT(*) FROM tb_BoardItem
WHERE BoardID=@BoardID
AND
BoardTitle like @SearchText
OR
UserName like @SearchText
OR
BoardContents like @SearchText)
END
Posted
Comments
Vincent Maverick Durano 22-Aug-16 13:17pm    
You need to pass the new page index at Page_Changed event to get the result for the current page. I would suggest you to debug your code. Set a break point at Page_Changed event, and then step into your codes to figure out what's going on.

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