I have this data Grid Set Up but It doesn't scroll through the database? I 've been looking through tutorials and it seems that it is the right code? Can someone see if they see a problem, Cause I cant and their is
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New SqlConnection(ConfiguratonSettings.AppSettings("strDBConn"))
Try
conn.Open()
Dim cmd As New SqlCommand("tenrows", conn)
ddpairs.DataSource = cmd.ExecuteReader()
ddpairs.DataBind()
If Not Page.IsPostBack Then
ddpairs.DataBind()
End If
Catch ex As Exception
lblerr.Text = ex.Message
End Try
conn.Close()
End Sub
Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.Click
End Sub
Private Sub NavigationButtonClicked(ByVal sender As Object, _
ByVal e As EventArgs) Handles btnfirst.Click, btnprevious.Click, btnnext.Click, btnlast.Click
Dim intcount As Integer
Dim conn As New SqlConnection(ConfigurationSettings.AppSettings("strDBConn"))
Dim direction As String = CType(sender, Button).CommandName
intcount = "Select Count(orderkey) From pairs"
Try
conn.Open()
Dim cmd As New SqlCommand("tenrows", conn)
ddpairs.DataSource = cmd.ExecuteReader()
Dim reader As SqlDataReader
Select Case direction.ToUpper()
Case "FIRST"
ddpairs.CurrentPageIndex = 0
Case "PREVIOUS"
ddpairs.CurrentPageIndex = _
Math.Max(0, ddpairs.CurrentPageIndex - 1)
Case "NEXT"
ddpairs.CurrentPageIndex = _
Math.Min(ddpairs.PageCount - 1, _
ddpairs.CurrentPageIndex + 1)
Case "LAST"
ddpairs.CurrentPageIndex = _
ddpairs.PageCount - 1
Case Else
End Select
Catch ex As Exception
lblerr.Text = ex.Message
End Try
conn.Close()
End Sub
Private Sub ddpairs_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles ddpairs.PageIndexChanged
ddpairs.CurrentPageIndex = e.NewPageIndex
ddpairs.DataBind()
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New SqlConnection(ConfiguratonSettings.AppSettings("strDBConn"))
Try
conn.Open()
Dim cmd As New SqlCommand("tenrows", conn)
ddpairs.DataSource = cmd.ExecuteReader()
ddpairs.DataBind()
If Not Page.IsPostBack Then
ddpairs.DataBind()
End If
Catch ex As Exception
lblerr.Text = ex.Message
End Try
conn.Close()
End Sub
Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.Click
End Sub
Private Sub NavigationButtonClicked(ByVal sender As Object, _
ByVal e As EventArgs) Handles btnfirst.Click, btnprevious.Click, btnnext.Click, btnlast.Click
Dim intcount As Integer
Dim conn As New SqlConnection(ConfigurationSettings.AppSettings("strDBConn"))
Dim direction As String = CType(sender, Button).CommandName
intcount = "Select Count(orderkey) From pairs"
Try
conn.Open()
Dim cmd As New SqlCommand("tenrows", conn)
ddpairs.DataSource = cmd.ExecuteReader()
Dim reader As SqlDataReader
Select Case direction.ToUpper()
Case "FIRST"
ddpairs.CurrentPageIndex = 0
Case "PREVIOUS"
ddpairs.CurrentPageIndex = _
Math.Max(0, ddpairs.CurrentPageIndex - 1)
Case "NEXT"
ddpairs.CurrentPageIndex = _
Math.Min(ddpairs.PageCount - 1, _
ddpairs.CurrentPageIndex + 1)
Case "LAST"
ddpairs.CurrentPageIndex = _
ddpairs.PageCount - 1
Case Else
End Select
Catch ex As Exception
lblerr.Text = ex.Message
End Try
conn.Close()
End Sub
Private Sub ddpairs_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles ddpairs.PageIndexChanged
ddpairs.CurrentPageIndex = e.NewPageIndex
ddpairs.DataBind()
End Sub