Code for alternating colored rows.

Discussion in 'ASP General' started by crab.dae@gmail.com, Jun 12, 2006.

  1. Guest

    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!!
     
    , Jun 12, 2006
    #1
    1. Advertising

  2. 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





    <> wrote in message
    news:...
    > 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!!
    >
     
    Aaron Bertrand [SQL Server MVP], Jun 12, 2006
    #2
    1. Advertising

  3. 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


    <> wrote in message
    news:...
    > 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!!
    >
     
    Ray Costanzo [MVP], Jun 12, 2006
    #3
  4. Mike Brind Guest

    wrote:
    > 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
     
    Mike Brind, Jun 12, 2006
    #4
  5. Guest

    Thanks for the info folks. Good to know there's quick help out there.
     
    , Jun 12, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MattC
    Replies:
    0
    Views:
    1,613
    MattC
    Mar 22, 2005
  2. Stuart Shay
    Replies:
    3
    Views:
    13,312
    Darkmoor
    Aug 20, 2010
  3. Replies:
    3
    Views:
    645
  4. Sachin
    Replies:
    1
    Views:
    392
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jun 1, 2007
  5. MangroveRoot

    alternating text/image rows

    MangroveRoot, Nov 4, 2007, in forum: HTML
    Replies:
    7
    Views:
    448
    Adrienne Boswell
    Nov 4, 2007
Loading...

Share This Page