Inherits System.Web.UI.Page
Protected Sub PageDropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim pagerRow As GridViewRow = CustomersGridView.BottomPagerRow
Dim pageList As DropDownList = CType(pagerRow.Cells(0).FindControl("PageDropDownList"), DropDownList)
CustomersGridView.PageIndex = pageList.SelectedIndex
End Sub
Protected Sub CustomersGridView_DataBound(ByVal sender As Object, ByVal e As EventArgs)
Dim pagerRow As GridViewRow = CustomersGridView.BottomPagerRow
Dim pageList As DropDownList = CType(pagerRow.Cells(0).FindControl("PageDropDownList"), DropDownList)
Dim pageLabel As Label = CType(pagerRow.Cells(0).FindControl("CurrentPageLabel"), Label)
If pageList IsNot Nothing Then
For i As Integer = 0 To CustomersGridView.PageCount - 1
Dim pageNumber As Integer = i + 1
Dim item As New ListItem(pageNumber.ToString())
If i = CustomersGridView.PageIndex Then
item.Selected = True
End If
pageList.Items.Add(item)
Next i
End If
If pageLabel IsNot Nothing Then
Dim currentPage As Integer = CustomersGridView.PageIndex + 1
pageLabel.Text = "Page " & currentPage.ToString() & " of " & CustomersGridView.PageCount.ToString()
End If
End Sub
End Class