Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack() Then
intPageSize.Text = "10" 'aqui indican el tamañano de la página
intCurrIndex.Text = "0" 'Inicializo el indice
Bind()
End If
End Sub
Private Sub Bind()
Dim objConn As New SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))
Dim objDA As New SqlDataAdapter("SELECT * FROM TABLA", objConn)
Dim objDS As New DataSet
If Not Page.IsPostBack() Then
objDA.Fill(objDS)
intRecordCount.Text = CStr(objDS.Tables(0).Rows.Count)
objDS = Nothing
objDS = New DataSet
End If
If intCurrIndex.Text = 0 Then
hrefPrevious.Visible = False
Else
hrefPrevious.Visible = True
End If
objDA.Fill(objDS, CInt(intCurrIndex.Text), CInt(intPageSize.Text), "Logs")
dList.DataSource = objDS.Tables(0).DefaultView
dList.DataBind()
objConn.Close()
PrintStatus()
End Sub
Public Sub
ShowFirst (ByVal s As Object, ByVal e As EventArgs)
intCurrIndex.Text = "0"
Bind()
End Sub
Public Sub
ShowPrevious (ByVal s As Object, ByVal e As EventArgs)
intCurrIndex.Text = CStr(CInt(intCurrIndex.Text) - CInt(intPageSize.Text))
If CInt(intCurrIndex.Text) < 0 Then
intCurrIndex.Text = "0"
End If
Bind()
End Sub
Public Sub
ShowNext (ByVal s As Object, ByVal e As EventArgs)
If CInt(intCurrIndex.Text) + 1 < CInt(intRecordCount.Text) Then
intCurrIndex.Text = CStr(CInt(intCurrIndex.Text) + CInt(intPageSize.Text))
End If
Bind()
End Sub
Public Sub
ShowLast (ByVal s As Object, ByVal e As EventArgs)
Dim tmpInt As Integer
tmpInt = CInt(intRecordCount.Text) Mod CInt(intPageSize.Text)
If tmpInt > 0 Then
intCurrIndex.Text = CStr(CInt(intRecordCount.Text) - tmpInt)
Else
intCurrIndex.Text = CStr(CInt(intRecordCount.Text) - CInt(intPageSize.Text))
End If
Bind()
End Sub
Private Sub PrintStatus()
lblStatus .Text = "Total Records:<b>" & intRecordCount.Text
lblStatus.Text += "</b> - Showing Page:<b> "
lblStatus.Text += CStr(CInt(CInt(intCurrIndex.Text) / CInt(intPageSize.Text) + 1))
lblStatus.Text += "</b> of <b>"
If (CInt(intRecordCount.Text) Mod CInt(intPageSize.Text)) > 0 Then
lblStatus.Text += CStr(CInt(CInt(intRecordCount.Text) / CInt(intPageSize.Text) + 1))
Else
lblStatus.Text += CStr(CInt(intRecordCount.Text) / CInt(intPageSize.Text))
End If
lblStatus.Text += "</b>"
End Sub