How to change client side isnullorempty to if statement

Posted on 2007-11-27
Last Modified: 2013-12-16
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.

<%# 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

Question by:fusioninternet
  • 4
  • 2
LVL 12

Expert Comment

ID: 20359129
In Javascript you can check IsNaN(value)

Author Comment

ID: 20359155
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?
LVL 12

Expert Comment

ID: 20359167
sorry .. wrong entry
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

LVL 12

Accepted Solution

needo_jee earned 500 total points
ID: 20359222

Author Closing Comment

ID: 31411216
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";
            return " " + String.Format("{0:£#.00}", Price) + " each";
LVL 12

Expert Comment

ID: 20382178

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Code works but I need to redo it and assign values to Model 7 32
Tool Box 2 34
IIS Authorization for Web Service 2 21
Web Form VB.Net  import CSV 4 24
In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now