This topic is locked

Conditional Formatting Custom Field as Short Date

8/25/2022 2:12:35 PM
ASPRunner.NET General questions
R
rl74martinez author

I have a field where I have applied conditional formatting using Custom field setting. The field is a date field in SQL Server. Here is my code.

string color;
if (data["DIAApproval_HH"] == 1) {
color="red";
}else {
color="black";
}
value="<span style='color: " + color + "'>" + value.ToString() + "</span>";

The issue I am having is that I need the date field to show as a short date. I tried changing the code to

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

but I am getting the following error message 'runnerDotNet.XVar' does not contain a definition for 'ToShortDateString

I also tried this

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

but I still get an error message.

Any help with this is greatly appreciated.

Thanks!