The first thing you need to do is create a database called MyDatabase. Then create a table called tblData with these fields:
ID - autonumber
Item - text field
DateEntered - date/time field *** Also add "=Date()" as the default value for the field. This will add the date automatically, everytime a new record is entered. ***
Then, start adding some data to your database. If you leave the database empty, the script will simply display a blank page.
Next, create a page called alternaterowcolor.asp and copy the below code into your page:
<% DIM mySQL, objRS mySQL = "SELECT * FROM tblData" Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open mySQL, objConn, adOpenKeySet
These are my database records. |
<% objRS("Item") %> |
<% iRecordCount = iRecordCount + 1 objRS.MoveNext Loop objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing %>
This will display the first record in gray and the second record in white and will continue to alternate the color of each row displayed on your page.
http://www.aspwebpro.com/aspscripts/database/alternaterowcolor.asp
No comments:
Post a Comment