Forum de discussion
Forum « Programmation ASP » (archives)
Re: Pagination du resultat à afficher sur un formulaire
Envoyé: 11 octobre 2004, 12h08 par Salem
cnn.open "DSN=CMS"
et
sql = "select * from networks where active = -1"
avec ta chaine de connexion et ta requete SQL
<%@ LANGUAGE="VBSCRIPT" %>
<% page = clng(request("page"))
order = request("order")
if page = 0 then page = 1
nbline = clng(request("lpp"))
if nbline <= 0 then nbline = 30
Set cnn = Server.CreateObject("ADODB.connection")
cnn.open "DSN=CMS"
Set rs_rep = Server.CreateObject("ADODB.Recordset")
sql = "select * from networks where active = -1"
%><html>
<head>
<STYLE TYPE="text/css">
<!--
BODY {font-family: Arial; font-size : 10pt; color: black}
TABLE {font-family: Arial; font-size : 10pt; color : black}
SELECT {font-family: Arial; font-size : 10px; color : #333333}
TEXTAREA {font-family: Arial; font-size : 10px; color : black}
INPUT {font-family: Arial; font-size : 10px; color : #333333}
A {font-family: Arial; font-size : 10px; color : #9C2021}
A.linkRojoG { font: bold 11px Verdana; color: rgb(156,32,33); text-decoration: underline; }
A.linkRojoG:hover { font: bold 11px Verdana; color: rgb(0,0,0); text-decoration: none; }
-->
</STYLE>
<title><% =view %></title>
<script>
current_view = '<% =view %>';
function get_page(pg)
{ document.frm.page.value=pg;
document.frm.submit();
}
</script>
</head>
<body>
<table bgcolor="#E2E2E2">
<% rs_rep.cursorlocation = 3
if order <> "" then
if right(order, 5) = " DESC" then
sql = sql & " order by [" & left(order, len(order) - 5) & "] DESC"
else
sql = sql & " order by [" & order & "]"
end if
end if
rs_rep.open sql, cnn
rs_rep.pageSize = nbline
nbpage = rs_rep.pageCount
if page > nbpage then page = 1
rs_rep.absolutePage = page
%><tr><form method="post" name="frm" onSubmit="get_page(this.page.value); return false;">
<input type="hidden" name="order" value="<% =order %>">
<td witdh="1"><input type="button" value="Precedent" onClick="get_page(<% =page-1 %>);"
<% if page=1 then response.write(" disabled") %>></td>
<td witdh="100%" align="center"> <input type="text" size="3" name="lpp" value="<% =nbline %>"> Ligne(s) par page | Charger la page
<input type="text" size="3" name="page" value="<% =page %>"> / <% =nbpage %> <input type="submit" value="Go"></td>
<td witdh="1" align="right"><input type="button" value="Suivant" onClick="get_page(<% =page+1 %>);"
<% if page=clng(nbpage) then response.write(" disabled") %>></td>
</form></tr>
<tr>
<td colspan="3"><table width="100%" bgcolor="#E2E2E2" cellpadding="2">
<tr class="titleBold"><% for each column in rs_rep.fields %>
<td><a href="#" onClick="document.frm.order.value='<%
if order = column.name then
response.write(column.name & " DESC")
else
response.write(column.name)
end if %>';get_page(<% =page %>);return false;"
<% if trim(order) = trim(column.name) or trim(order) = trim(column.name & " DESC") then response.write("class=""linkRojoG""") %>>
<% =column.name %></a></td>
<% next %></tr>
<% for x = 1 to nbline
if not rs_rep.eof then %>
<tr bgcolor="#FFFFFF"><% for each column in rs_rep.fields
select case column.type
case 202: %><td><% =column.value %></td><%
case 135: %><td><% =simple_date(column.value) %></td><%
case 3, 11: %><td align="center"><% =column.value %></td><%
case else: %><td><% =column.value %></td><%
end select
next %></tr>
<% rs_rep.movenext:
end if
next %>
</table> <% =rs_rep.recordcount %> enregistrement(s) au total</td>
</tr>
<% rs_rep.close: set rs_rep = Nothing %>
</table>
</body>
</html>
<% cnn.close: set cnn = Nothing
function simple_date(dt)
if dt then
simple_date = day(dt) & "-" & monthname(month(dt), -1) & "-" & year(dt)
else
simple_date = ""
end if
end function
%>
Réponses
|