?
Solved

How to change client side isnullorempty to if statement

Posted on 2007-11-27
6
Medium Priority
?
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 12

Expert Comment

by:Munawar Hussain
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:Munawar Hussain
ID: 20359167
sorry .. wrong entry
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 12

Accepted Solution

by:
Munawar Hussain earned 2000 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:Munawar Hussain
ID: 20382178
Cheers...
Thanks
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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 …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 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