Foros del Web » Programando para Internet » ASPX (.net) »

Paginar con un ListView

Estas en el tema de Paginar con un ListView en el foro de ASPX (.net) en Foros del Web. ¿Es posible paginar con un ListView?...
  #1 (permalink)  
Antiguo 15/01/2006, 10:34
Avatar de RsOfT  
Fecha de Ingreso: marzo-2002
Ubicación: InterNET
Mensajes: 1.121
Antigüedad: 22 años, 1 mes
Puntos: 7
Paginar con un ListView

¿Es posible paginar con un ListView?
__________________
.::RsOfT::.
--El que se aferra a lo conocido, nunca conocerá lo desconocido--
--Es intentando lo imposible como se realiza lo posible--
--Es de pésimo gusto contentarse con algo mediocre cuando lo excelente está a nuestro alcance--
  #2 (permalink)  
Antiguo 07/05/2006, 04:35
Avatar de affv  
Fecha de Ingreso: diciembre-2002
Ubicación: Ahora aqui
Mensajes: 485
Antigüedad: 21 años, 4 meses
Puntos: 0
Alguien podria responder esta consulta.
Esque estoy con la misma duda.
__________________
Todo tiene un comienzo y un fin!!
Postea tus proyectos
  #3 (permalink)  
Antiguo 07/05/2006, 23:10
Avatar de affv  
Fecha de Ingreso: diciembre-2002
Ubicación: Ahora aqui
Mensajes: 485
Antigüedad: 21 años, 4 meses
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
__________________
Todo tiene un comienzo y un fin!!
Postea tus proyectos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:39.