Private Property currentPageIndex() As Integer
Get
Return Convert.ToInt32(ViewState("currentPage"))
End Get
Set(ByVal value As Integer)
ViewState("currentPage") = value
End Set
End Property
Private Sub BindControl()
(เรียกฐานข้อมูลมาใส่ใน DataTable โดยกำหนดชื่อ DataTable ว่า dt)
Dim dv As DataView = dt.DefaultView
Dim pd As New PagedDataSource()
pd.DataSource = dv
pd.PageSize = 5
pd.AllowPaging = True
pd.CurrentPageIndex = currentPageIndex
(ชื่อปุ่มBack).Enabled = Not (pd.IsFirstPage)
(ชื่อปุ่มNext).Enabled = Not (pd.IsLastPage)
(ชื่อRepeater).DataSource = pd
(ชื่อRepeater).DataBind()
End Sub
Protected Sub btnGoBack_Click(sender as object,e as eventArgs)
currentPageIndex -= 1
BindControl()
End Sub
Protected Sub btnGoNext_Click(sender as object,e as eventArgs)
currentPageIndex += 1
BindControl()
End Sub