gpt4 book ai didi

telerik - GridView (RadGrid) 和自定义分页

转载 作者:行者123 更新时间:2023-12-04 16:41:38 25 4
gpt4 key购买 nike

好的,所以我试图让我的自定义分页在 Telerik RadGrid 上进行(类似于 asp:Gridview ),但我仍然碰壁。 (我的问题的第一部分已回答 here )
所以我已经实现了这个建议。我使用以下存储过程

ALTER PROCEDURE [dbo].[bt_HealthMonitor_GetAll]
(
@StartRowIndex int,
@MaximumRows int
)

AS
SET NOCOUNT ON

Select
RowNum,
[ID],
[errEx],
[errURL],
[errSource],
[errUser],
[errMessage],
[errIP],
[errBrowser],
[errOS],
[errStack],
[errDate],
[errNotes]
From
(
Select
[ID],
[errEx],
[errURL],
[errSource],
[errUser],
[errMessage],
[errIP],
[errBrowser],
[errOS],
[errStack],
[errDate],
[errNotes],
Row_Number() Over(Order By [ID]) As RowNum
From dbo.[bt_HealthMonitor] t
)
As DerivedTableName
Where RowNum Between @StartRowIndex And (@StartRowIndex + @MaximumRows)

Order By [ID] Desc
然后另一个存储过程来获取记录数
ALTER PROCEDURE [dbo].[bt_HealthMonitor_GetRecordCount]

AS
SET NOCOUNT ON

return (Select Count(ID) As TotalRecords From bt_HealthMonitor)
我正在使用 LINQ to SQL 绑定(bind)到我的 RadGrid
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs)

Dim startRowIndex As Integer = (RadGrid1.CurrentPageIndex * RadGrid1.PageSize)
Dim maximumRows As Integer = RadGrid1.PageSize

Dim HealthMonitorDC As New DAL.HealthMonitorDataContext

Dim r = HealthMonitorDC.bt_HealthMonitor_GetAll(startRowIndex, maximumRows)
RadGrid1.DataSource = r
End Sub

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
Dim HealthMonitorDC As New DAL.HealthMonitorDataContext
Dim count = HealthMonitorDC.bt_HealthMonitor_GetRecordCount()
RadGrid1.MasterTableView.VirtualItemCount = count.ReturnValue
RadGrid1.VirtualItemCount = count.ReturnValue
End Sub
但我遇到的问题是网格只抓取前 10 行(如预期的那样),但我需要获取它,以便它能够识别表中有 200 行,以便显示分页图标。
如果我使用下拉列表显示 50 条记录,那么会显示 50 条,但仍然没有分页图标让我进入下一个 50 条。
我究竟做错了什么?

最佳答案

您需要告诉网格总共有多少条记录。这是通过设置网格的 VirtualItemCount 来完成的。属性(您必须查询总记录数)。

详情请看documentation page或引用 online demo for custom paging .

关于telerik - GridView (RadGrid) 和自定义分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2397862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com