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

Paginar un DataList

Estas en el tema de Paginar un DataList en el foro de ASPX (.net) en Foros del Web. Hola amigos del foro, alguien sabe si existe alguna forma relativamente sencilla para paginar un DataList como lo hace el grid, o se debe realizar ...
  #1 (permalink)  
Antiguo 14/02/2008, 12:29
 
Fecha de Ingreso: noviembre-2007
Ubicación: Trabajo en INEGI
Mensajes: 33
Antigüedad: 16 años, 5 meses
Puntos: 0
Paginar un DataList

Hola amigos del foro, alguien sabe si existe alguna forma relativamente sencilla para paginar un DataList como lo hace el grid, o se debe realizar una implementación minusiosa para presentar y controlar la paginación.

Esto debido a que debo presentar una plantilla de la informacion de un productos, pero a su vez son demasiados registros, por lo cual requiero paginar el DataList.

algo parecido al FormView, una combinacion de DataList y GridView

Gracias
  #2 (permalink)  
Antiguo 18/02/2008, 14:52
 
Fecha de Ingreso: mayo-2007
Mensajes: 2
Antigüedad: 17 años
Puntos: 0
Re: Paginar un DataList

Te envio un ejemplo que lo encontré por ahi, y funciona...

Chispas, es un poco largo... pongo el que NO necesita un datasource, para que tengas una idea, y si te complicas escribes otra ves...

Saludos..

Pd. Pega todo en una un webform



<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<script runat="server">
Dim pagedData As New pagedDataSource

Sub Page_Load(byVal obj As Object, byVal e As EventArgs)
doPaging()
End Sub

Sub doPaging()
Dim mockData As New HashTable()
Dim IDx As Integer = 0
Do Until IDx = 500
mockData.Add(IDx.toString(), (IDx * 101).toString)
IDx += 1
Loop

pagedData.DataSource = mockData
pagedData.AllowPaging = True
pagedData.PageSize = 5

Try
pagedData.CurrentPageIndex = Int32.Parse(Request.QueryString("Page")).ToString( )
Catch ex As Exception
pagedData.CurrentPageIndex = 0
End Try

btnPrev.Visible = ( NOT pagedData.IsFirstPage )
btnNext.Visible = ( NOT pagedData.IsLastPage )

theDataList.DataSource = pagedData
theDataList.DataBind()
End Sub

Public Sub Prev_Click(ByVal obj As Object, ByVal e As EventArgs)
Response.Redirect(Request.CurrentExecutionFilePath & "?Page=" & (pagedData.CurrentPageIndex - 1))
End Sub

Public Sub Next_Click(ByVal obj As Object, ByVal e As EventArgs)
Response.Redirect(Request.CurrentExecutionFilePath & "?Page=" & (pagedData.CurrentPageIndex + 1))
End Sub

</script>
<html>
<head>
<title>Paging with ASP.NET - HashTable Example - VB.NET</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form runat="server">
<asp:DataList id="theDataList" runat="server">
<ItemTemplate>
<hr size="0" />
Department: <%# DataBinder.Eval(Container.DataItem, "Key") %><br />
Employee ID: <%# DataBinder.Eval(Container.DataItem, "Value") %></a><br />
</ItemTemplate>
</asp:DataList>
<asp:LinkButton id="btnPrev" Text="&lt;" OnClick="Prev_Click" runat="server" />
<asp:LinkButton id="btnNext" Text="&gt;" OnClick="Next_Click" runat="server" />
</form>
</body>
</html>
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 05:46.