优秀的软件开发团队:深圳升蓝软件 数据库开发 .Net技术  |  ASP技术 PHP技术 JSP技术 应用技术类     
热门推荐
升蓝OA办公自动化系统
基于.Net技术的网络
协同办公环境
 
ASP基础
数据库相关
安全加密
全文检索
ASP应用
打印相关
客户端相关
XML相关
系统相关
正则表达式
ASP技巧
组件开发
脚本编码
FSO专题
邮件相关
远程脚本
性能优化
 
相关链接
深圳升蓝软件:系统集成、办公自动化平台、电子商务、电子政务、Web数据库、企业网站、游戏、手机应用程序、CDMA软件、电子出版物等,为客户提供优秀的解决方案
 
升蓝(www.hi-blue.com)为企业管理、政府办公提供成熟的、易于实施的IT技术服务,我们的解决方案包括OA办公自动化系统CRM客户关系管理系统ERP企业生产管理和订单管理系统电子政务系统、知识管理系统、企业门户、商业智能、工程项目管理等等...
 
电子政务解决方案
塑料/橡胶管理系统
知识管理系统简介
多媒体光盘方案
ERP企业资源管理
订单计划管理系统
PM工程项目管理系统
会员管理系统
相关资料下载
OA办公自动化系统
CRM客户关系管理系统
在线试用版本说明
OA 系统的用户手册
 
 
 
 
升蓝开发团队 > 技术资料 > ASP技术 > ASP应用 : 分页显示的例子(显示记录背景色替换变化)

分页显示的例子(显示记录背景色替换变化)


March 25,2004
Code Title: Paging (modifiable)
Description: Add paging to your record retrieval. But, do it with the good'ol form field that allows you
to just type in directly what page ya wanna go to. This one is our fave! It even alternates the background
color (bgcolor) of each row, to make viewing the recordset even easier.. We use different tweaked versions
of this one all over our site! See an example of this code snippet on our International page.

We have made it so that it will display a hyperlinked first item in one column, then a truncated
description using the Left() function in the next column. The hyperlink will take you to the specific
article or record, (whatever you're using it for).

We use a javascript valid number checker on this one, just to make sure the person doesn't enter any weird
characters into the page number field of the form. We don't normally do this, but if ya want the
javascript for number checking, check out our jsNumberValidator.
Copy and paste this snippet as-is into your editor:


<%
Const adUseClient = 3
Const adOpenStatic = 3
specific = Request.QueryString("specific")
If specific = "" Then
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = adUseClient
rs.CacheSize = 5
mypage = Request.Form("pgNum")
If  mypage = "" Then mypage = 1
rs.Open "SELECT * FROM TABLE ORDER BY FIELD ASC", cnDZ, adOpenStatic
If Not rs.EOF Then
  rs.MoveFirst
  rs.PageSize = 20 'change this number to exactly how many records per page ya wanna show
  maxcount = cint(rs.PageCount)
  rs.AbsolutePage = mypage
  howmanyrecs = 0
  Response.Write"<table border=0>"
  LinkCount = 0
  While Not rs.EOF And howmanyrecs < rs.pagesize
  If LinkCount Mod 2 = 0 Then bgColor = " bgcolor=#F0F0F0" Else bgColor = ""
  Response.Write"<tr"&bgColor&"><td nowrap>"&_
   "<a href=""myPage.asp?specific="&rs("ID")&""">"&rs("FIELD")&"</a></td>"&_
   "<td width=""100%"" nowrap>"&Left(rs("FIELD2"),40)&"</td></tr>"
  LinkCount = LinkCount + 1
  rs.MoveNext
  howmanyrecs = howmanyrecs + 1
  Wend
  Response.Write"</table>"
  If maxcount > 1 Then
   If mypage + 1 > maxcount Then nextPg = 1 Else nextPg = mypage + 1
   Response.Write"<form method=post action=""myPage.asp"">"&_
    "<nobr>Page "&mypage&" of "&maxcount&"      Navigate to Page:<input
type=text name=pgNum size=3 maxlength=3 value="""&nextPg&""">  <input type=submit name=gopgNum
value=GO></nobr></form>"
  End If
Else Response.Write"Sorry, nothing is available at the moment."
End If
rs.Close
Set rs = Nothing
Else
Set rs = cnDZ.Execute("SELECT * FROM TABLE WHERE ID = "&specific&"")
Do Until rs.EOF
Response.Write""&rs("FIELD")&"<br>"&_
  ""&rs("FIELD2")&"<br>"
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End If
%>


       
数据库开发 | .Net技术 | ASP技术 | PHP技术 | JSP技术 | 应用技术类 | 升蓝开发小组
Copyright ? 2001-2004 Shenzhen Hi-blue Software Team 升蓝开发小组 All rights reserved