[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 129
  • Last Modified:

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.
0
Southern_Gentleman
Asked:
Southern_Gentleman
  • 3
  • 2
  • 2
1 Solution
 
Kyle AbrahamsSenior .Net DeveloperCommented:
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" %>'
0
 
Southern_GentlemanAuthor Commented:
Thanks Kyle, keep coming with an error.

BC30108: 'TimeSpan' is a type and cannot be used as an expression.
0
 
Scott Fell, EE MVEDeveloperCommented:
Somebody asked a very similar question earlier today.  Here is my solution using momentjs  http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28474242.html#a40191345

This was for 30 days but you can see where you can adjust as needed.   This is a front end / client side solution.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Kyle AbrahamsSenior .Net DeveloperCommented:
Try DateTime.TimeSpan instead of just the timespan.
0
 
Southern_GentlemanAuthor Commented:
Thanks Scott, got it to work like a champ.
0
 
Scott Fell, EE MVEDeveloperCommented:
Awesome!    Did you use momentjs?
0
 
Southern_GentlemanAuthor Commented:
Yes, I then added it to the cell style of my gridview.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now