Foros del Web » Programando para Internet » ASP Clásico »

Paginación

Estas en el tema de Paginación en el foro de ASP Clásico en Foros del Web. Algún script para paginar mis páginas con datos desde la db? Gracias....
  #1 (permalink)  
Antiguo 09/03/2005, 06:14
 
Fecha de Ingreso: febrero-2005
Mensajes: 10
Antigüedad: 20 años, 2 meses
Puntos: 0
Paginación

Algún script para paginar mis páginas con datos desde la db?
Gracias.
  #2 (permalink)  
Antiguo 09/03/2005, 07:53
Avatar de comarine  
Fecha de Ingreso: enero-2003
Ubicación: Ciudad Autónoma de Buenos Aires
Mensajes: 48
Antigüedad: 22 años, 3 meses
Puntos: 0
Hola, acá va uno que espero te sirva. Pagina 3 registros por página para cambiarlo buscá la palabra ACA (y después borrala).

Saludos


<%@Language=VBScript%>
<%Response.Buffer=True%>
<!--#include file="dsn.asp"-->
<%
'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3

'---- CommandTypeEnum Values ----
Const adCmdUnknown = &H0008
Const adCmdText = &H0001
Const adCmdTable = &H0002
Const adCmdStoredProc = &H0004
Const adCmdFile = &H0100
Const adCmdTableDirect = &H0200

Dim strSQL, objRS, Operador, Nada
Dim Registro
Dim Pagina

fecha = year(date) & "/" & month(date) & "/" & day(date)

strSQL = "SELECT * " &_
"FROM (contenidos INNER JOIN menu_perfil ON contenidos.sec = menu_perfil.id_menu) " &_
"INNER JOIN usuarios ON menu_perfil.id_perfil = usuarios.perfil " &_
"WHERE usuarios.perfil = " & session("perfil") & " " &_
" AND vigencia_desde <= '" & fecha & "'" &_
" AND vigencia_hasta >= '" & fecha & "'" &_
" AND (titulo like '%" & request.querystring("cadena") & "%' " &_
" OR texto_nota like '%" & request.querystring("cadena") & "%' " &_
" OR descripcion like '%" & request.querystring("cadena") & "%') " &_
" ORDER BY vigencia_desde DESC "

If Request("Pagina") = "" Then
Pagina = 1
Else
Pagina = clng(Request("Pagina"))
End If

Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.Open strSQL, Conn, adOpenStatic, adCmdText
objRS.Pagesize = 3 <!-- ACA -->
If objRS.RecordCount > 0 then
objRS.AbsolutePage = Pagina
End If
%>

<html>

<head>
<title></title>
<link rel="stylesheet" href="estilos.css" type="text/css">
<script language="javascript" src="js/afoto.js"></script>
<script language="javascript" src="js/mini_foto.js"></script>
<script language="javascript" src="js/neowin.js"></script>
</head>

<body>

<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td class="titulo_busca" valign="middle">Search Result - total: <%=objRS.RecordCount%> records (page <%=pagina%> of <%=objRS.PageCount%>)</td>
<td class="titulo2_busca" align="right" valign="middle">
<%
If Pagina > 1 Then
%>
<a class="titulo2_busca" href="buscador.asp?cadena=<%=request.querystring(" cadena")%>&Pagina=<%=Pagina-1%>&descripcion=<%=Request("DESCRIPCION")%>&notas= <%=Request("NOTAS")%>&gacetillas=<%=Request("GACET ILLAS")%>&imagenes=<%=Request("IMAGENES")%>" title="Anteriror">&lt;&lt;</a>&nbsp;
<%
Else
%>
::&nbsp;
<%
End If
C = 0
If Pagina + 5 <= objRS.PageCount Then
I = Pagina
Else
I = objRS.PageCount - 4
If I <= 0 Then
I = 1
End If
End If
While (I <= objRS.PageCount And C < 5)
If I = Pagina Then
response.write I & "&nbsp;"
Else
%>
<a class="titulo2_busca" href="buscador.asp?cadena=<%=request.querystring(" cadena")%>&Pagina=<%=I%>&descripcion=<%=Request("D ESCRIPCION")%>&notas=<%=Request("NOTAS")%>&gacetil las=<%=Request("GACETILLAS")%>&imagenes=<%=Request ("IMAGENES")%>"><%=I%></a>&nbsp;
<%
End If
I = I + 1
C = C + 1
Wend
If Pagina < objRS.PageCount Then
%>
<a class="titulo2_busca" href="buscador.asp?cadena=<%=request.querystring(" cadena")%>&Pagina=<%=Pagina+1%>&descripcion=<%=Req uest("DESCRIPCION")%>&notas=<%=Request("NOTAS")%>& gacetillas=<%=Request("GACETILLAS")%>&imagenes=<%= Request("IMAGENES")%>" title="Siguiente">&gt;&gt;</a>&nbsp;
<%
Else
%>
::&nbsp;&nbsp;
<%
End If
%>
</td>
</tr>
</table>
<table border="0" cellpadding="2" cellspacing="3" width="100%">
<%
Registro=0
While (Registro < 3) And (Not objRS.EOF) <!-- ACA -->
%>
<tr><td height="3"><img src="imagenes/inv.gif" height="3"></td></tr>
<tr>
<td class="tit_busca" valign="top"><img src="imagenes/cuadraditos.gif" border="0">&nbsp;Type</td>
<td class="datos_busca" align="left" valign="top">
<%
Select Case objRS("ID_TIPO_CONTENIDO")
Case 11 : Response.Write "note"
Case 20 : Response.Write "popup"
Case 30 : Response.Write "images"
Case 98 : Response.Write "event"
End Select
%>
</td>
<td class="tit_busca" valign="top"><img src="imagenes/cuadraditos.gif" border="0">&nbsp;Validity</td>
<td class="datos_busca" align="left" valign="top"><%=objRS("VIGENCIA_DESDE") & " - " & objRS("VIGENCIA_HASTA")%></td>
</tr>
<tr>
<td class="tit_busca" valign="top"><img src="imagenes/cuadraditos.gif" border="0">&nbsp;Title</td>
<td class="datos_busca" align="left" valign="top" colspan="3">
<%
If objRS("ID_TIPO_CONTENIDO") <> 30 Then
%>
<a class="datos_busca" target="right" href="nota.asp?id_contenido=<%=objRS("id_contenido ")%>"><%=objRS("TITULO")%></a></td>
<%
else
response.write objRS("TITULO")
end if
%>
</td>
</tr>
<tr>
<td class="tit_busca" valign="top"><img src="imagenes/cuadraditos.gif" border="0">&nbsp;Description</td>
<td class="datos_busca" align="left" valign="top" colspan="3">
<%
If objRS("ID_TIPO_CONTENIDO") = 30 Then
%>
<a class="datos_busca" href="#" onClick="afoto('upload/contenido/<%=objRS("zip_download")%>','<%=objRS("TITULO")%>' );return false">
<script>minifoto("upload/catalogo/<%=objRS("zip_download")%>",48,48);</script></a>
<%
Else
if len(objRS("descripcion")) > 100 then
response.write mid(objRS("descripcion"),1,200) & " ..."
else
response.write mid(objRS("descripcion"),1,200) & "&nbsp;"
end if
End If
%>
</td>
</tr>
<%
if registro <> 2 then
%>
<tr><td class="bottom" height="3" colspan="4"><img src="imagenes/inv.gif" height="3"></td></tr>
<%
end if
Registro = Registro + 1
objRS.MoveNext
Wend
objRS.Close()
Set objRS = Nothing
%>
</table>
</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 10:02.