I'm trying to dynamically populate a table in my ASP.NET webpage from an Azure Storage Table and one of the features I wanted to include is to change the color of the text depending on the value of the element.
I'm using a DataList
object which is calling a GetEntries()
method to get a list of all the objects to display.
The text in each cell of the table is dynamically displayed using:
<%# Eval("VariableName") %>
So I tried changing the color of the text by doing something like this for each object in the GetEntries()
method:
if (condition)
VariableName = "<font color=\"red\">" + VariableName + "</font>";
else
// ...
When I run my program, the text is still black and when I view source, the <font color="red">Bob</font
is only Bob
.
Does the HTML get stripped when using Eval?
If so, is there an efficient way to change the text color based on the values?
Thanks!