473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Conditional Operator in ASP

I'm trying to code a line in my .asp that will check for one of three values
in a field and either:

a) if null, no display

b) if set to -.01, show the "Please call..."

c) show the price

I can't see how my code below is failing, but I get an error

error CS0131: The left-hand side of an assignment must be a variable,
property or indexer

Any ideas?

Using .net 2.0 and VSE 2005

Thanks.

<%# (Double.Parse(DataBinder.Eval(Container.DataItem,
"SalePrice").ToString()) = 0) ? "" :

(Double.Parse(DataBinder.Eval(Container.DataItem, "SalePrice").ToString())
= -.01) ? "<font color=\"#ff0000\">Please call for price" :

"Special price: </b><font color=\"#ff0000\">" +
DataBinder.Eval(Container.DataItem, "SalePrice", "{0:c}")%>
Sep 1 '06 #1
2 1678
Hi

Replace the "=" operator with "==" . This the actual equalto operator.

1. = -.01 should be == -.01
2. = 0) ? should == 0) ?

Hope this helps

Prem

"Brad Farrell" wrote:
I'm trying to code a line in my .asp that will check for one of three values
in a field and either:

a) if null, no display

b) if set to -.01, show the "Please call..."

c) show the price

I can't see how my code below is failing, but I get an error

error CS0131: The left-hand side of an assignment must be a variable,
property or indexer

Any ideas?

Using .net 2.0 and VSE 2005

Thanks.

<%# (Double.Parse(DataBinder.Eval(Container.DataItem,
"SalePrice").ToString()) = 0) ? "" :

(Double.Parse(DataBinder.Eval(Container.DataItem, "SalePrice").ToString())
= -.01) ? "<font color=\"#ff0000\">Please call for price" :

"Special price: </b><font color=\"#ff0000\">" +
DataBinder.Eval(Container.DataItem, "SalePrice", "{0:c}")%>
Sep 1 '06 #2
Talk about a bone head mistake. Thanks!

B
"Prem Kumar" <Pr*******@discussions.microsoft.comwrote in message
news:0E**********************************@microsof t.com...
Hi

Replace the "=" operator with "==" . This the actual equalto operator.

1. = -.01 should be == -.01
2. = 0) ? should == 0) ?

Hope this helps

Prem

"Brad Farrell" wrote:
>I'm trying to code a line in my .asp that will check for one of three
values
in a field and either:

a) if null, no display

b) if set to -.01, show the "Please call..."

c) show the price

I can't see how my code below is failing, but I get an error

error CS0131: The left-hand side of an assignment must be a variable,
property or indexer

Any ideas?

Using .net 2.0 and VSE 2005

Thanks.

<%# (Double.Parse(DataBinder.Eval(Container.DataItem,
"SalePrice").ToString()) = 0) ? "" :

(Double.Parse(DataBinder.Eval(Container.DataIte m,
"SalePrice").ToString())
= -.01) ? "<font color=\"#ff0000\">Please call for price" :

"Special price: </b><font color=\"#ff0000\">" +
DataBinder.Eval(Container.DataItem, "SalePrice", "{0:c}")%>

Sep 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: TheKeith | last post by:
I just wrote the following script for something I'm working on: ---------------------------------------------------------------------------- ------------------- <html> <head> <script...
26
by: Ney André de Mello Zunino | last post by:
Hello. I have noticed, in a lot of C and C++ code, that many programmers seem to prefer putting the test values first in conditional expressions. I.e., they would rather write this: if (-1 ==...
6
by: Mahesh Tomar | last post by:
Please see the code below :- void func() { unsigned char x,y,z=1; (z==1) ? (x) : (y) = 1; /* Compiles OK */ ((z==1) ? (x) : (y)) = 1; /* Compiler generates an error "Variable expected" */ }
4
by: mux | last post by:
Hi I found out that the following piece of code throws an error. 1 #include "stdio.h" 2 3 int main() 4 { 5 int a,b; 6 a= 10;
6
by: Chris Dunaway | last post by:
Consider this code (.Net 2.0) which uses a nullable type: private void button1_Click(object sender, System.EventArgs e) { DateTime? nullableDate; nullableDate = (condition) ? null :...
9
by: Marty | last post by:
Hi, Does using the the conditional operator (?:) instead of the common "if" statement will give a performance gain in a C# .NET 2003 application (even in C# .NET 2005?). What is the advantage...
5
by: paulo | last post by:
Can anyone please tell me how the C language interprets the following code: #include <stdio.h> int main(void) { int a = 1; int b = 10; int x = 3;
15
by: Nicholas M. Makin | last post by:
I was just thinking that I understood the conditional operator when I coded the following expecting it to fail: int a= 10, b= 20, c= 0; ((a < b) ? a : b) = c; // a=0 a=20; b= 10; ((a < b) ? a...
3
by: somenath | last post by:
Hi All, I have one question regarding the conditional operator. In the draft C99 standard it is mentioned that "1 The following are the sequence points described in 5.1.2.3: -- The call to a...
13
by: Neal Becker | last post by:
In hindsight, I am disappointed with the choice of conditional syntax. I know it's too late to change. The problem is y = some thing or other if x else something_else When scanning this my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.