Compare Dates and Differentiate with Colour Shades

Tips submitted by ASP.NET Maker users

Compare Dates and Differentiate with Colour Shades

Postby xgis » Tue Aug 06, 2013 12:43 am

This sample shows how to check for no date and also compare dates by displaying expired dates with a lighter shade.
It may also be applied to the Row_Rendering event. This may be enhanced further but it does the basics.

// Row Rendered event
public void Row_Rendered() {
if (InspectionDateNext.CurrentValue is System.DBNull) {
InspectionDateNext.CellCssStyle = "background-color: #FFE680"; }
else if (Convert.ToDateTime(InspectionDateNext.CurrentValue) > Convert.ToDateTime(DateTime.Today)){
InspectionDateNext.CellCssStyle = "background-color: #D8E79D"; }
else if (Convert.ToDateTime(InspectionDateNext.CurrentValue) < Convert.ToDateTime(DateTime.Today)){
InspectionDateNext.CellCssStyle = "background-color: #f0f6da"; }
}
xgis
 
Posts: 87
Joined: Thu Jan 17, 2013 10:40 pm

Re: Compare Dates and Differentiate with Colour Shades

Postby xgis » Thu Dec 05, 2013 8:20 am

This method works with single row EDIT but does not work with GRID EDIT.
xgis
 
Posts: 87
Joined: Thu Jan 17, 2013 10:40 pm


Return to User Submited Tips (ASP.NET Maker)