Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
can i do multiple bgcolors in a table in asp
Old 04-13-2004, 01:23 PM can i do multiple bgcolors in a table in asp
Junior Talker

Posts: 1
Trades: 0
hi folks, hoping someone can help me out with this one:
I have a report.asp page where i display data from an Access query. I know how to set my table so that each row will alternate 2 colors back and forth, but can i set the background color, based on a value in a field.

When someone enters data in my form, one of the fields is called "recency" Here they must select whether the data is "new", "ongoing", or "expired". These are text fields in my db.

Soooo, when i show all my records in my report, I want to be able to base the bgcolor for a particular recordset, based on the value that record has in it's "recency" field. i.e if that recordset has "new" in the Recency field, then display the row background in green, if it is "ongoing", then the row background should be yellow, etc etc

Any ideas?
Here is a couple lines of my code where i display the data:
Code:
  <tr VALIGN="TOP">
    <td><%Response.Write RS("planno")%></td>
    <td><%Response.Write RS("type")%></td>
    <td><%Response.Write RS("company")%></td>
  </tr>
jaberwocky is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-14-2004, 04:23 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
Right before displaying the table row I would put a case statement in. Something like this:
Code:
<%
dim strBGColor
select case rs("recency")
   case "new"
      strBGColor = "green"
   case "ongoing"
      strBGColor = "yellow"
   case "expired"
      strBGColor = "red"
   case else
      'Logic for alternating row colors here
      if altrow then
         strBGColor = "white"
      else
         strBGColor = "lightgrey"
      end if
end select
%>
  <tr>
    <td bgcolor="<%=strBGColor%>><%= RS("planno")%></td>
    <td bgcolor="<%=strBGColor%>><%= RS("type")%></td>
    <td bgcolor="<%=strBGColor%>><%= RS("company")%></td>
  </tr>
That should give you a start.

You could also create a 2 dimensional array to store the status/color combo and loop through the array comparing the status with the records status and assign strBGColor a color value that way. That would eliminate the case statement which cuts down on the number of lines of code. It would also make updating it easier.
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 06-01-2004, 03:56 PM
Novice Talker

Posts: 14
Trades: 0
Or you could just use COLOR="******" for each one! (If you have a set amount of cells...)
jonnyfb is offline
Reply With Quote
View Public Profile
 
Old 06-03-2004, 05:55 PM
Novice Talker

Posts: 11
Trades: 0
right you could use bgcolor="" for each <TD> though the ASP Solution is nicer and better
__________________
GoToTrafficSchool.Com -
Please login or register to view this content. Registration is FREE

TeenDrivingCourse.Com -
Please login or register to view this content. Registration is FREE
TrafficSchool is offline
Reply With Quote
View Public Profile Visit TrafficSchool's homepage!
 
Reply     « Reply to can i do multiple bgcolors in a table in asp
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19632 seconds with 12 queries