Marius Vasile

Marius Vasile

  • 590
  • 1.9k
  • 148.6k

asp.net core if condition is not working properly

May 8 2021 9:26 AM
I have three different situations to apply color to div based on if conditions. the single ones (first and third) are working properly the middle one is not. Values exists, already checked. What am I doing wrong?
 
  1. @if (item.RiskLevelF < Model.GreenHL)  
  2.                             {  
  3.                                 <div class="col-md-3">  
  4.                                     <span class="form-control" style="background-color:limegreen">@Html.DisplayFor(model => item.RiskLevelF)</span>  
  5.                                 </div>  
  6.                             }  
  7.                             @if ((item.RiskLevelF > Model.GreenHL) && (item.RiskLevelF < Model.YellowHL))  
  8.                             {  
  9.                                 <div class="col-md-3">  
  10.                                     <span class="form-control" style="background-color:yellow">@Html.DisplayFor(model => item.RiskLevelF)</span>  
  11.                                 </div>  
  12.                             }  
  13.                             @if (item.RiskLevelF > Model.YellowHL)  
  14.                             {  
  15.                                 <div class="col-md-3">  
  16.                                     <span class="form-control text-white" style="background-color:red">@Html.DisplayFor(model => item.RiskLevelF)</span>  
  17.                                 </div>  
  18.                             }  
 

Answers (5)