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