nVelocity - Template issue when attempting 'greater than' comparison on decimal property

Posted by Bart on Stack Overflow See other posts from Stack Overflow or by Bart
Published on 2010-03-24T06:55:34Z Indexed on 2010/03/24 7:03 UTC
Read the original article Hit count: 682

Filed under:
|
|
|

I have a simple object that has as one of it's properties a decimal named Amount. When I attempt a comparison on this property as part of an nVelocity template, the comparison always fails. If I change the property to be of type int the comparison works fine. Is there anything extra I need to add to the template for the comparison to work?

Below is a sample from the aforementioned template:

#foreach( $bet in $bets )
<li>
 $bet.Date $bet.Race 
 #if($bet.Amount > 10)
  <strong>$bet.Amount.ToString("c")</strong>
 #else
  $bet.Amount.ToString("c")
 #end
</li>
#end

Below is the Bet class:

public class Bet
{
    public Bet(decimal amount, string race, DateTime date)
    {
       Amount = amount;
       Race = race;
       Date = date;
    }

    public decimal Amount { get; set; }
    public string Race { get; set; }
    public DateTime Date { get; set; }
}

Any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about nvelocity

Related posts about template