如何对gridview中的特定行进行排序(如何制作SQL) [英] How can I sort the specific rows in gridview(how to make SQL)
问题描述
您好!
我正在制作网站,现在我正在使用GridView构建电路板。
它需要自定义分页,一些行必须放在列表的顶部(每一页)
我正在使用这些网站建立我的网站/>
使用GridView自定义分页
有人帮我,我完成了下面的make存储过程,bur排序不起作用
如果BoardNotice值为Y,那些行必须放在列表顶部,N值行
放在下面。 ..喜欢这个
BoardTitle用户名BoardNotice
测试约翰Y
test2 tom Y
test3 jo N
test4 zoey N
test5 carter N
test6 tony N
请修改我的代码或给我一些建议..谢谢
我尝试了什么:
更改程序[dbo]。[TestCustomPaging]
@BoardID int --FK(PK在tb_BoardMaster,我有3个板子)
,@ PageIndex int
,@ PageSize int
,@ RecordCount int输出
AS
BEGIN
设定开启数量;
;用cte作为(
SELECT
ROW_NUMBER()OVER(订单来自I.BoardItemID desc)AS indexNO
,I。 BoardItemID - PK
,I.BoardTitle
,I.UserName
,I.BoardRegDate
,I .BoardHit
,I.BoardNotice - 验证通知与否(默认值为N(不通知))
,(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
你好再次Rydenchoi
尝试添加:ORDER BY I.BoardNotice
SELECT $ p> p> span> * FROM cte
WHERE
indexNO BETWEEN ( @ PageIndex -1)* @ PageSize +1 AND ((( @ PageIndex -1)* @ PageSize +1)+ @ PageSize )-1
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
Hi again Rydenchoi
try adding this:ORDER BY I.BoardNotice DESCafter
SELECT * FROM cte WHERE indexNO BETWEEN (@PageIndex -1) * @PageSize +1 AND (((@PageIndex -1) * @PageSize +1) + @PageSize) -1
这篇关于如何对gridview中的特定行进行排序(如何制作SQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!