Solved

How to change client side isnullorempty to if statement

Posted on 2007-11-27
6
208 Views
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.

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
Comment
Question by:fusioninternet
  • 4
  • 2
6 Comments
 
LVL 12

Expert Comment

by:needo_jee
Comment Utility
In Javascript you can check IsNaN(value)
0
 
LVL 1

Author Comment

by:fusioninternet
Comment Utility
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
 
LVL 12

Expert Comment

by:needo_jee
Comment Utility
sorry .. wrong entry
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 12

Accepted Solution

by:
needo_jee earned 500 total points
Comment Utility
0
 
LVL 1

Author Closing Comment

by:fusioninternet
Comment Utility
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
 
LVL 12

Expert Comment

by:needo_jee
Comment Utility
Cheers...
Thanks
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

12 Experts available now in Live!

Get 1:1 Help Now