I'm trying to get paging to work. I either get the same page to just stay there or get the first page and when I hit the page number button everything vanishes.
Imports System.Data.OleDb
Imports System.Data.SqlTypes
Imports System.Data.SqlDbType
Imports system.Data.SqlClient
Imports system.Data
Imports System.ComponentModel
Imports System.Collections
Imports System.Web.UI.WebControls
Partial Class _Default
Inherits System.Web.UI.Page
Dim grabline As String
Dim ranks As New DataSet
Dim GRABTXT As New SqlConnection
Dim grab1 As New SqlCommand
Dim GRAB2 As New SqlCommand
'
Public GRAB As New SqlConnection("connection string")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then
Else
Me.grdranks.AllowPaging = True
Me.grdranks.PageSize = 3
grabline = "Select rank_id, "
grabline = grabline + " female_rank_name "
grabline = grabline + " from distributors.dbo.rank "
grabline = grabline + " order by rank_id "
'
Dim grab1 As New SqlCommand(Me.grabline, GRAB)
'
Dim G1 As New SqlDataAdapter(grab1)
Dim G2 As New DataSet
'
Dim GAB As New SqlDataAdapter(grab1)
GAB.Fill(ranks, "THERANK")
'
Dim x3b = ranks.Tables("THERANK").Rows.Count
'
grdranks.DataSource = ranks.Tables("THERANK")
grdranks.DataBind()
'
grdranks.Visible = True
GRAB.Close()
End If
End Sub
Protected Sub grdranks_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdranks.PageIndexChanging
Dim grab1 As New SqlCommand(Me.grabline, GRAB)
'
Dim G1 As New SqlDataAdapter(grab1)
Dim G2 As New DataSet
'
Dim GAB As New SqlDataAdapter(grab1)
GAB.Fill(ranks, "THERANK")
grdranks.DataSource = ranks.Tables("THERANK")
grdranks.PageIndex = e.NewPageIndex
grdranks.DataBind()
grdranks.Visible = True
End Sub
Protected Sub grdranks_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdranks.PageIndexChanged
End Sub
End Class
Imports System.Data.OleDb
Imports System.Data.SqlTypes
Imports System.Data.SqlDbType
Imports system.Data.SqlClient
Imports system.Data
Imports System.ComponentModel
Imports System.Collections
Imports System.Web.UI.WebControls
Partial Class _Default
Inherits System.Web.UI.Page
Dim grabline As String
Dim ranks As New DataSet
Dim GRABTXT As New SqlConnection
Dim grab1 As New SqlCommand
Dim GRAB2 As New SqlCommand
'
Public GRAB As New SqlConnection("connection string")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then
Else
Me.grdranks.AllowPaging = True
Me.grdranks.PageSize = 3
grabline = "Select rank_id, "
grabline = grabline + " female_rank_name "
grabline = grabline + " from distributors.dbo.rank "
grabline = grabline + " order by rank_id "
'
Dim grab1 As New SqlCommand(Me.grabline, GRAB)
'
Dim G1 As New SqlDataAdapter(grab1)
Dim G2 As New DataSet
'
Dim GAB As New SqlDataAdapter(grab1)
GAB.Fill(ranks, "THERANK")
'
Dim x3b = ranks.Tables("THERANK").Rows.Count
'
grdranks.DataSource = ranks.Tables("THERANK")
grdranks.DataBind()
'
grdranks.Visible = True
GRAB.Close()
End If
End Sub
Protected Sub grdranks_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdranks.PageIndexChanging
Dim grab1 As New SqlCommand(Me.grabline, GRAB)
'
Dim G1 As New SqlDataAdapter(grab1)
Dim G2 As New DataSet
'
Dim GAB As New SqlDataAdapter(grab1)
GAB.Fill(ranks, "THERANK")
grdranks.DataSource = ranks.Tables("THERANK")
grdranks.PageIndex = e.NewPageIndex
grdranks.DataBind()
grdranks.Visible = True
End Sub
Protected Sub grdranks_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdranks.PageIndexChanged
End Sub
End Class