Solved

How to change client side isnullorempty to if statement

Posted on 2007-11-27
6
212 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
ID: 20359129
In Javascript you can check IsNaN(value)
0
 
LVL 1

Author Comment

by:fusioninternet
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?
0
 
LVL 12

Expert Comment

by:needo_jee
ID: 20359167
sorry .. wrong entry
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 12

Accepted Solution

by:
needo_jee earned 500 total points
ID: 20359222
0
 
LVL 1

Author Closing Comment

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

Expert Comment

by:needo_jee
ID: 20382178
Cheers...
Thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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