ASP: simple alternating colour rows in a dynamic table
There is a very simple way of presenting a dynamic table with alternate colours for rows. In order to achieve this effect we can use CSS and ASP.
First of all, prepare the CSS style for your rows as follow:
Now create your dynamic table:
Please note that the table we created has a class called "sample": what we are doing is simply alternating its tag class, between d0 and d1.
The final effect is this:
And that's all.
First of all, prepare the CSS style for your rows as follow:
The background-color determines the colours you will use for the rows. In our example, it will be two shades of blue.Now create your dynamic table:
First Column Header
Second Column Header
Third Column Header
<%j=0%>
<%
While Not rs.EOF%>
<%j = j + 1
Response.write ""%>
<%=rs.Fields.Item("fieldname1").value%>
<%=rs.Fields.Item("fieldname2").value%>
<%=rs.Fields.Item("fieldname3").value%>
<%
rs.MoveNext
Wend
%>
Please notice that rs is actually the name of the recordset you have previously opened (I will not give here the code for the recordset handling).Please note that the table we created has a class called "sample": what we are doing is simply alternating its
The final effect is this:
First Column Header Second Column Header Third Column Header 1 2 3 4 5 6 7 8 9 10 11 ...
And that's all.