Microsoft
Software
Hardware
Network
Question : Color coding results based on value in a table on an ASP page
Hello experts. I have an ASP page that contains a table pulling data from a SQL server database. Below is the code of that table:
<table width="527" border="4" cellpadding="2" cellspacing="2" id=MyTable>
<thead>
<tr>
<td><font size="-1"><b>Agent</b></fo
nt></td>
<td><b><font size="-1">State Description</font></b></td
>
<td><b><font size="-1">Reason</font></b
></td>
<td><font size="-1"><b>Duration</b><
/font></td
>
</tr>
</thead>
<% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) %>
<tr>
<td><font size="-1"><%=(Recordset1.F
ields.Item
("agent").
Value)%></
font></td>
<td><font size="-1"><%=(Recordset1.F
ields.Item
("StateDes
cription")
.Value)%><
/font></td
>
<td><font size="-1"><%=(Recordset1.F
ields.Item
("Reason")
.Value)%><
/font></td
>
<td><font size="-1"><%=(Recordset1.F
ields.Item
("duration
").Value)%
></font></
td>
</tr>
<%
Repeat1__index=Repeat1__in
dex+1
Repeat1__numRows=Repeat1__
numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
The field "StateDescription" in the database contains only 3 possible text values--"Ready", "Not Ready", and "Busy". What I want to do is to have the field "Agent" change color based on the value in the corresponding "StateDescription" field. For example, for any row of data in the table that shows a StateDescription value of "Busy", I want the agent's name in the Agent field to turn blue, for any row that shows a StateDescription value of "Not Ready", I want the agent's name in the Agent field to turn red, and so on.
I have exhaustively looked for how to manage this through ASP, Javascript, and SQL, and cannot seem to find exactly the right code to handle the conditional formatting of data where text is concerned. The closest I've seen is the insertion of ASP code within the <td></td> tags, but haven't been able to get it to completely work (all rows of data showed the same color).
I am offering 500 points for this due to the urgency of having this answer available...thank you in advance!!
Answer : Color coding results based on value in a table on an ASP page
hi, in that case try using trim with the select case statement
select case trim(Recordset1.Fields.Ite
m("StateDe
scription"
).Value)
Random Solutions
Restoring Windows Server 2008 System state backup on different machine
iSCSI Performance Tuning
Yum v. 3.2.22 throws segmentation fault no matter which command i issue to it on centos 5.4.
Folders from Windows Updates are created in USB Discs
Is there a DSMOD query to change the domain part (only) of an email address in AD?
How do I delete a file from a folder (uploads directory) when I delete its reference in the database?
Cisco 1310g Wireless Bridge, Fastethernet Hardware Status Down
Windows 2003 DC, want to install DNS but setup fails on missing file(s). (dnsperf.h)
After moving mailbox to Exchange 2007 lost all Outlook rules
Dell Inspiron 1012 - Multimedia Controller Driver