WelcomeServicesPortfolioKnowledge BaseContact Us
27 Seconds, Inc.


Knowledge base View Article

need hosting?

Need hosting? We use and love our host - CrystalTech.com!
Need hosting? We use and love our host - CrystalTech.com!

Text Disguise - CAPTCHA-image/Human Interactive Proof web services

National Holiday Dates and Bank Holiday Dates - web site that provides the dates of national and bank holidays for the United States, United Kingdom, Ireland and Scotland

Holiday Web Service - web services for programmers to provide the dates of national and bank holidays in their applications for the United States, United Kingdom, Ireland and Scotland

Our Family Heart - web site to help families communicate no matter where they are

What?! You haven't heard about the greatest remote controlled flyer to come out in years?! Checkout the FlyTech DragonFly now!

Alternating BG Color When Displaying a Recordset

Summary: When displaying a large recordset, it is helpful to alternate the background colors.
 
Keywords: ALT
ALTERNATE
ASP
BACKGROUND
BG
COLOR
COLOUR
MOVENEXT
RECORDSET
RS
Applicable Software: Active Server Pages (ASP)
ADO
HTML
Microsoft Access
Microsoft SQL Server
 
Body:

There are many solutions to alternating the background color. Generally, you take a variable and just swap it from one color to another.

I recently saw a solution posted on ASPMessageBoard.com that took an array of colors to rotate through and used that. It was simple, yet elagent:

Dim Cnt
Dim BGColors
	BGColors = Array("white", "gray", "blue")

Cnt = -1
While Not Recordset.EOF
	Cnt = Cnt + 1

	Response.Write "<tr bgcolor='" & BGColors(Cnt MOD (UBound(BGColors) + 1)) & "'>"
	Response.Write "<td>" & Recordset(1) & "</td>"
        Response.Write "</tr>"

	Recordset.MoveNext
Wend

To add change the number of colors. You only need to change the line:

BGColors = Array("white", "gray", "blue")

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 11/29/2002 9:18:39 AM

Rate this article: Average: 5
n/a12345678910
Comments?

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.