07/05/2006, 23:10
|
| | | Fecha de Ingreso: diciembre-2002 Ubicación: Ahora aqui
Mensajes: 485
Antigüedad: 22 años, 1 mes Puntos: 0 | |
Tambien lo logre y dejo el ejemplo por si a alguien mas le sirve.
default.aspx
Código:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:datalist ID="dList" runat="server" Width="100%" RepeatColumns="3">
<ItemTemplate>
<%# Eval("Id")%>
</ItemTemplate>
</asp:DataList>
<asp:label id="lblStatus" Font-Size="10pt" Font-Names="Verdana" Runat="server"></asp:label>
<asp:label id="intCurrIndex" Runat="server"></asp:label>
<asp:label id="intPageSize" Runat="server"></asp:label>
<asp:label id="intRecordCount" Runat="server" ></asp:label>
<hr />
<a id="hrefFirst" href="default.aspx#this" runat="server" onserverclick="ShowFirst" ><<</a>
<a id="hrefPrevious" href="#" runat="server" onserverclick="ShowPrevious "><</a>
<a id="hrefNext" href="#" runat="server" onserverclick="ShowNext ">></a>
<a id="hrefLast" href="#" runat="server" onserverclick="ShowLast ">>></a>
</div>
</form>
</body>
</html>
default.aspx
Código:
Imports System.Data.Odbc
Imports System.Data
Partial Class default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack() Then
intPageSize.Text = "9" '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 OdbcConnection("Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Data.mdb;")
Dim objDA As New OdbcDataAdapter("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
End Class
|