Hello!
I`m making website, and now I`m building board using GridView.
it needed custom paging and some rows must be placed on the top of the list(every page)
I`m building my girdview using this sites
Custom Paging with GridView
someone helped me, and I completed the make stored procedure below, bur sorting is not working
if BoardNotice value is Y, that rows must be placed on the top of the list and N value rows
placed below... like this
BoardTitle UserName BoardNotice
test john Y
test2 tom Y
test3 joe N
test4 zoey N
test5 carter N
test6 tony N
Please, fix my code or some advice to me.. thanks
What I have tried:
ALTER PROCEDURE [dbo].[TestCustomPaging]
@BoardID int --FK(PK in tb_BoardMaster, I have 3 Boards)
, @PageIndex int
, @PageSize int
, @RecordCount int output
AS
BEGIN
SET NOCOUNT ON;
;with cte as (
SELECT
ROW_NUMBER() OVER (ORDER BY 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
)
SELECT * FROM cte
WHERE
indexNO BETWEEN (@PageIndex -1) * @PageSize +1 AND (((@PageIndex -1) * @PageSize +1) + @PageSize) -1
END