This topic is locked

conditional formatting the cell value color - list page

9/1/2021 6:02:28 PM
ASPRunner.NET Tips and tricks
S
stefansuba author

Hi ,
I am trying to do conditional formatting the cell value color in asprunner but no luck . I red articles about this ,went over the tutorial but it is stil not working . I am hoping ,someone will be able to help me . I am using asprunner 10.4 and i have a table with a column named "order_status" and the lookup list values are "Overdue , Complete and In progress" . I woul like to have diferent collors for each status .

I tried to add this in C# under custom / in view as tab

string color;

if (value > 0) {

color="black";

value="Complete";
}else {

color="red";

}

value="<span style='color: " + color + "'>" + value.ToString() + "</span>";

I am having complitaions errors

if strValue < 0 then
color="black"
text = "complete"
else
color="red"
text="overdue"
end if
strValue="<span style='color: " & color & ";'>" & text & "</span>"

compilation error

Thank you ,

SS

F
Frank R 9/1/2021

What event are you placing that code in? The examples for this in the help do work.

S
stefansuba author 9/1/2021

Hi Frank ,
I followed the instructions in the help :

To set the formatting, proceed to the Page Designer, click on the field you wish to format (the profitability field in our case), then click View as/Edit as. Select View as Custom option. Add the code in the custom code editor:

string color;

if (value > 0) {

color="black";

}else {

color="red";

}

value="<span style='color: " + color + "'>" + value.ToString() + "</span>"

S
stefansuba author 9/1/2021
admin 9/2/2021

It would be benefitial if you post your exact code and the exact error message. Also, use code formatting options in this forum to make it readable.

Right now I can see two different code snippets and no error message.