Link to home
Start Free TrialLog in
Avatar of Southern_Gentleman
Southern_GentlemanFlag for United States of America

asked on

Red Font for Dates 21 > than today

I'm using ASP.net and have a gridview with a date column. I'm trying to highlight in redfont all the dates that are 21 days greater than Todays current date. I have a css .redfont with bold font-weight. I'd like to do this as an itemtemplate. What the way to do this via EVAL.
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

on the item template you should be able to set the class

class = '<%# ((TimeSpan) DateTime.Now - DateTime.Parse(Eval("StartDate").ToString())).Days > 21 ? "redClass" : "NormalClass" %>'
Avatar of Southern_Gentleman

ASKER

Thanks Kyle, keep coming with an error.

BC30108: 'TimeSpan' is a type and cannot be used as an expression.
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try DateTime.TimeSpan instead of just the timespan.
Thanks Scott, got it to work like a champ.
Awesome!    Did you use momentjs?
Yes, I then added it to the cell style of my gridview.