In some cases you may need to colour fields based on a range of selections.
The example below uses colours to differentiate levels of risk using decimal / float values.
For discrete values (ie integers) you could use "=" and change Convert.ToDouble to Convert.ToInt32
The control example in this case is a drop down with stored values ranging from 1-5.
The colour range is amber to red as any decision indicates risk, whereas no selection (null) indicates no risk.
The code; (replace "EnvERRSoilContVisAssID" with your field name)
if (EnvERRSoilContVisAssID.CurrentValue is System.DBNull) {
EnvERRSoilContVisAssID.CellCssStyle = "background-color: #FF8C69"; }
else if (Convert.ToDouble(EnvERRSoilContVisAssID.CurrentValue) <= 1.5 ){
EnvERRSoilContVisAssID.CellCssStyle = "background-color: #FFD966"; }
else if (Convert.ToDouble(EnvERRSoilContVisAssID.CurrentValue) <= 2.5 ){
EnvERRSoilContVisAssID.CellCssStyle = "background-color: #F9C475"; }
else if (Convert.ToDouble(EnvERRSoilContVisAssID.CurrentValue) <= 3.5 ){
EnvERRSoilContVisAssID.CellCssStyle = "background-color: #F4B084"; }
else if (Convert.ToDouble(EnvERRSoilContVisAssID.CurrentValue) <= 4.5 ){
EnvERRSoilContVisAssID.CellCssStyle = "background-color: #F68C77"; }
else if (Convert.ToDouble(EnvERRSoilContVisAssID.CurrentValue) > 4.5 ){
EnvERRSoilContVisAssID.CellCssStyle = "background-color: #F8696B"; }