Code for alternating colored rows.

C

crab.dae

Not sure if any one can help but I'm loading data into a table that
I've like to alternate the background color of the rows (White then
pink). Can someone tell me what I need to add to do this?
======================================================
While Not rsData.EOF

response.write "<tr><td width=225 align=left><font size=1>"
response.Write rsData("NAME")
response.Write "</font></td>"
response.write "<td width=225 align=left><font size=1>"
response.Write rsData("ADDRESS")
response.Write "</font></td>"
response.write "<td width=225 align=left><font size=1>"
response.Write rsData("PHONE")
response.Write "</font></td></tr>"

rsData.MoveNext

WEnd
=======================================================

Thanks!!
 
A

Aaron Bertrand [SQL Server MVP]

First, stop using WHILE...WEND... use DO...LOOP instead. Also, you should
use CSS classes instead of deprecated tags like <font> but we can deal with
that in a client-side group. For now,




color = "red"
Do While Not rsData.EOF
If color = "red" Then
color = "blue"
Else
color = "red"
End If
Response.Write "<tr bgcolor='" & color & "'>"
Response.Write "other stuff"
rsData.MoveNext()
Loop
 
R

Ray Costanzo [MVP]

Dim b
b = True
While Not rsData.EOF
If b Then
Response.Write "<tr style=""background-color: #codeforpink"">"
Else
Response.Write "<tr style=""background-color: #ffffff;"">"
End If
b = Not b
Response.Write "<td>........"
'...code
Response.Write "</tr>"
rsData.MoveNext
Wend
%>



While Not rsData.EOF

response.write "<tr><td width=225 align=left><font size=1>"
response.Write rsData("NAME")
response.Write "</font></td>"
response.write "<td width=225 align=left><font size=1>"
response.Write rsData("ADDRESS")
response.Write "</font></td>"
response.write "<td width=225 align=left><font size=1>"
response.Write rsData("PHONE")
response.Write "</font></td></tr>"

rsData.MoveNext

WEnd
 
M

Mike Brind

Not sure if any one can help but I'm loading data into a table that
I've like to alternate the background color of the rows (White then
pink). Can someone tell me what I need to add to do this?
======================================================
While Not rsData.EOF

response.write "<tr><td width=225 align=left><font size=1>"
response.Write rsData("NAME")
response.Write "</font></td>"
response.write "<td width=225 align=left><font size=1>"
response.Write rsData("ADDRESS")
response.Write "</font></td>"
response.write "<td width=225 align=left><font size=1>"
response.Write rsData("PHONE")
response.Write "</font></td></tr>"

rsData.MoveNext

WEnd
=======================================================

Thanks!!

Did you google?

http://www.google.co.uk/search?hl=en&q=alternating+row+colour+asp+-net&btnG=Google+Search&meta=

--Mike Brind
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top