This topic is locked
[SOLVED]

 Conditional row background color

7/7/2014 10:51:43 AM
ASPRunner.NET General questions
T
Tim author

Hello,
On a list page, I'm trying to dynamically change the background color of a row, based on the value of a field. I can do it if the color is "hard coded", like so:
if (data["Flag"] != "")

{

row["rowstyle"]="style=\"background:#82A0F5\"";

}
But I would like the color to be dynamic and based on the value of another field. Here is what I've tried:
if (data["Flag"] != "")

{

row["rowstyle"]="style=\"background:"" + data["FlagColor"].ToString + ""\"";

}
I've actually tried several other variations as well, but none of them work. Can someone help me with the syntax here?
Thanks,

Tim

Sergey Kornilov admin 7/7/2014

ToString is a function and needs to be called as a function (as opposed to property). Also quotes are all messed up.
Try this:

if (data["Flag"] != "")

{

row["rowstyle"]="style=\"background:" + data["FlagColor"].ToString() + "\"";

}
T
Tim author 7/8/2014

Thanks so much! I figured the quotes were messed up. I was thrown by the color coding of in the events screen. It makes sense now.
Thanks,

Tim