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

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

How to change client side isnullorempty to if statement

Hi Experts,
I have the following code inplace in the item template of a  repeater to only display certain text if the variable is null or empty and other text if it is not.

The problem i have is that the field (SalePrice) being checked in the database no longer stores a null value, the value is a money variable and now stores either a price or 0.
If anybody can help me in making this statement check for 0 now rather than null it would be greatly appreciated.

Regards
Steve
<%# String.IsNullOrEmpty(Convert.ToString(Eval("SalePrice"))) ? "<span class='price'> " + String.Format("{0:£#.00}", Eval("Price")) + "</span><span class='pertile'>each</span><br />" :  "<spane class=offertext>" + String.Format("{0:£#.00}", Eval("SalePrice"))+ "</span><span class='pertile'>each</span><br />" %>

Open in new window

0
fusioninternet
Asked:
fusioninternet
  • 4
  • 2
1 Solution
 
Munawar HussainPrincipal Software EngineerCommented:
In Javascript you can check IsNaN(value)
0
 
fusioninternetAuthor Commented:
Sorry I don't know javascript. Can I still do that within a repeater and still read the other values depending on the result of the check?
0
 
Munawar HussainPrincipal Software EngineerCommented:
sorry .. wrong entry
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Munawar HussainPrincipal Software EngineerCommented:
0
 
fusioninternetAuthor Commented:
This answer lead me to the solution. For reference below is what i have inplace and it works a treat.
<%# CheckSale(Convert.ToDecimal(Eval("SalePrice")), Convert.ToDecimal(Eval("Price")))%>

and in the .cs file the following
   public string CheckSale(decimal SalePrice, decimal Price)
    {
        if (SalePrice > 0)
            return "RRP " + String.Format("{0:£#.00}", Price) + "
" + "Now " + String.Format("{0:£#.00}", SalePrice) + "each";
        else
            return " " + String.Format("{0:£#.00}", Price) + " each";
    }
0
 
Munawar HussainPrincipal Software EngineerCommented:
Cheers...
Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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