📄 defaultvb.aspx.vb
字号:
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports Telerik.QuickStart
Imports Telerik.QuickStart.Grid
Imports Telerik.WebControls
Namespace Telerik.GridExamplesVBNET.GeneralFeatures.Paging
Public MustInherit Class DefaultVB
Inherits XhtmlPage
Protected WithEvents RadGrid1 As RadGrid
Protected WithEvents RadGrid2 As RadGrid
Protected WithEvents RadGrid3 As RadGrid
Protected WithEvents RadGrid4 As RadGrid
#Region "Web Form Designer generated code"
Protected Overrides Sub OnInit(ByVal e As EventArgs)
InitializeComponent()
MyBase.OnInit(e)
End Sub
Private Sub InitializeComponent()
End Sub
#End Region
Private Sub RadGrid1_NeedDataSource(ByVal [source] As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
RadGrid1.DataSource = DataSourceHelperVB.GetDataTable("SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers")
End Sub
Private Sub RadGrid2_NeedDataSource(ByVal [source] As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles RadGrid2.NeedDataSource
RadGrid2.DataSource = DataSourceHelperVB.GetDataTable("SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers")
End Sub
Private Sub Radgrid3_NeedDataSource(ByVal [source] As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles RadGrid3.NeedDataSource
RadGrid3.DataSource = DataSourceHelperVB.GetDataTable("SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers")
End Sub
'Custom paging
Private start_index As Integer = 0
'Prepare a set of items only for the selected page
Function CreateDataSource() As DataView
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn("ID", GetType(Int32)))
dt.Columns.Add(New DataColumn("Property1", GetType(String)))
dt.Columns.Add(New DataColumn("Property2", GetType(Double)))
Dim i As Integer
For i = start_index To (start_index + RadGrid4.MasterTableView.PageSize) - 1
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + (1 + i).ToString()
dr(2) = (100 - (i + 1))
dr(2) = 1.23 * (100 - (i + 1))
dt.Rows.Add(dr)
Next i
Return dt.DefaultView
End Function
Private Sub Radgrid4_PageIndexChanged(ByVal [source] As Object, ByVal e As Telerik.WebControls.GridPageChangedEventArgs) Handles RadGrid4.PageIndexChanged
'Update start index when page index changes
start_index = e.NewPageIndex * RadGrid4.MasterTableView.PageSize
End Sub
Private Sub Radgrid4_NeedDataSource(ByVal [source] As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles RadGrid4.NeedDataSource
RadGrid4.DataSource = Me.CreateDataSource()
End Sub
End Class
End Namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -