It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term && 14 1387
On Thu, 21 Jun 2007 13:19:41 -0700, bb****@yahoo.com wrote:
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if ((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17); {
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
Check the parens ( maybe):
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15)&& (Convert.ToInt32(e.Row.Cells[2].Text)>=17)) ;
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
<bb****@yahoo.comwrote in message
news:11*********************@e9g2000prf.googlegrou ps.com...
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
You've got your parentheses slightly confused:
if((Convert.ToInt32(e.Row.Cells[2].Text)>=15)&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17))
-- http://www.markrae.net
re:
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
You need to use the "regular" AND operator.
Try :
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
If you use && and e.Row.Cells[2].Text)>=15 is false, e.Row.Cells[2].Text)>=17
is not evaluated (because the result of the AND operation is false no matter what the
value of e.Row.Cells[2].Text)>=17 may be).
This is known as "short-circuit" evaluation...but it requires *both* operands to be true.
In your code, that is not alsways the case.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
<bb****@yahoo.comwrote in message news:11*********************@e9g2000prf.googlegrou ps.com...
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
The problem is a bit more than just misplaced parens.
See my just-sent explanation.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Turkbear" <no***@nowhere.comwrote in message news:91********************************@4ax.com...
On Thu, 21 Jun 2007 13:19:41 -0700, bb****@yahoo.com wrote:
>It says invalid expression term &&
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
if ((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17); {
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
Check the parens ( maybe):
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15)&& (Convert.ToInt32(e.Row.Cells[2].Text)>=17)) ;
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
Hi Juan,
In this case, "invalid expression term &&" is caused definitely by misplaced
parentheses, because it is a compiler message ;-) (evaluation would be done
at the runtime). Second, bitwise and & operator will give the same result
(apart from the fact short-circuit is not apllicable) because true & true =
true, false & true = false, false & false = false. Therefore, it should be
corrected to:
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
Best regards
--
Milosz
"Juan T. Llibre" wrote:
re:
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
You need to use the "regular" AND operator.
Try :
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
If you use && and e.Row.Cells[2].Text)>=15 is false, e.Row.Cells[2].Text)>=17
is not evaluated (because the result of the AND operation is false no matter what the
value of e.Row.Cells[2].Text)>=17 may be).
This is known as "short-circuit" evaluation...but it requires *both* operands to be true.
In your code, that is not alsways the case.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
<bb****@yahoo.comwrote in message news:11*********************@e9g2000prf.googlegrou ps.com...
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
Hi, Milosz,
In that case, what happens if Convert.ToInt32(e.Row.Cells[2].Text = 14) ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:85**********************************@microsof t.com...
Hi Juan,
In this case, "invalid expression term &&" is caused definitely by misplaced
parentheses, because it is a compiler message ;-) (evaluation would be done
at the runtime). Second, bitwise and & operator will give the same result
(apart from the fact short-circuit is not apllicable) because true & true =
true, false & true = false, false & false = false. Therefore, it should be
corrected to:
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
Best regards
--
Milosz
"Juan T. Llibre" wrote:
>re: ((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
You need to use the "regular" AND operator.
Try :
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
If you use && and e.Row.Cells[2].Text)>=15 is false, e.Row.Cells[2].Text)>=17 is not evaluated (because the result of the AND operation is false no matter what the value of e.Row.Cells[2].Text)>=17 may be).
This is known as "short-circuit" evaluation...but it requires *both* operands to be true. In your code, that is not alsways the case. Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== <bb****@yahoo.comwrote in message news:11*********************@e9g2000prf.googlegrou ps.com...
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
Good morning Juan
Did you mean if the text in cell equals "14"
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
then statement inside is not going to be reached, simply because the first
condition is false, and short-circuit evaluation for && operator skips the
second operand. I understand your confusion as I have seen this guy's
previous post, but in this case it was just misplaced parentheses ;-)
--
Milosz
"Juan T. Llibre" wrote:
Hi, Milosz,
In that case, what happens if Convert.ToInt32(e.Row.Cells[2].Text = 14) ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:85**********************************@microsof t.com...
Hi Juan,
In this case, "invalid expression term &&" is caused definitely by misplaced
parentheses, because it is a compiler message ;-) (evaluation would be done
at the runtime). Second, bitwise and & operator will give the same result
(apart from the fact short-circuit is not apllicable) because true & true =
true, false & true = false, false & false = false. Therefore, it should be
corrected to:
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
Best regards
--
Milosz
"Juan T. Llibre" wrote:
re:
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
You need to use the "regular" AND operator.
Try :
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
If you use && and e.Row.Cells[2].Text)>=15 is false, e.Row.Cells[2].Text)>=17
is not evaluated (because the result of the AND operation is false no matter what the
value of e.Row.Cells[2].Text)>=17 may be).
This is known as "short-circuit" evaluation...but it requires *both* operands to be true.
In your code, that is not alsways the case.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
<bb****@yahoo.comwrote in message news:11*********************@e9g2000prf.googlegrou ps.com...
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
re:
!Did you mean if the text in cell equals "14"
Yes.
re:
!then statement inside is not going to be reached, simply because the first
!condition is false, and short-circuit evaluation for && operator skips the second operand.
That's exactly what I explained...and that's an undesirable "feature".
That's why he needs to change the operator.
re:
!I understand your confusion
There's no confusion.
He should change both the parens *and* the operator,
the first as you suggest; the second as I suggest.
Doing that will cover all the bases for him.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:71**********************************@microsof t.com...
Good morning Juan
Did you mean if the text in cell equals "14"
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
then statement inside is not going to be reached, simply because the first
condition is false, and short-circuit evaluation for && operator skips the
second operand. I understand your confusion as I have seen this guy's
previous post, but in this case it was just misplaced parentheses ;-)
--
Milosz
"Juan T. Llibre" wrote:
>Hi, Milosz,
In that case, what happens if Convert.ToInt32(e.Row.Cells[2].Text = 14) ?
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message news:85**********************************@microso ft.com...
Hi Juan,
In this case, "invalid expression term &&" is caused definitely by misplaced
parentheses, because it is a compiler message ;-) (evaluation would be done
at the runtime). Second, bitwise and & operator will give the same result
(apart from the fact short-circuit is not apllicable) because true & true =
true, false & true = false, false & false = false. Therefore, it should be
corrected to:
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
Best regards
--
Milosz
"Juan T. Llibre" wrote:
re: ((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
You need to use the "regular" AND operator.
Try :
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
If you use && and e.Row.Cells[2].Text)>=15 is false, e.Row.Cells[2].Text)>=17 is not evaluated (because the result of the AND operation is false no matter what the value of e.Row.Cells[2].Text)>=17 may be).
This is known as "short-circuit" evaluation...but it requires *both* operands to be true. In your code, that is not alsways the case. Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== <bb****@yahoo.comwrote in message news:11*********************@e9g2000prf.googlegro ups.com...
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
Juan,
Come on, i can't see any logical exlanation in changing && operator to & for
this case :-). First of all, logically, his "if" statement could be
simplified changed to:
if (Convert.ToInt32(e.Row.Cells[2].Text) >= 17)
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
simply because the only numbers that meet both criteria are >= 17. Second,
if the first operand (Convert.ToInt32(e.Row.Cells[2].Text) >= 15) would
return false, second could not be true (logically). Please also note he used
&& therefore there is not point to test the second operand as you're trying
to point out. Third, it was definitely compiler error (syntax error) which
has nothing to do with runtime evaluation.
Take it easy mate ;-)
Best regards
--
Milosz
"Juan T. Llibre" wrote:
re:
!Did you mean if the text in cell equals "14"
Yes.
re:
!then statement inside is not going to be reached, simply because the first
!condition is false, and short-circuit evaluation for && operator skips the second operand.
That's exactly what I explained...and that's an undesirable "feature".
That's why he needs to change the operator.
re:
!I understand your confusion
There's no confusion.
He should change both the parens *and* the operator,
the first as you suggest; the second as I suggest.
Doing that will cover all the bases for him.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:71**********************************@microsof t.com...
Good morning Juan
Did you mean if the text in cell equals "14"
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
then statement inside is not going to be reached, simply because the first
condition is false, and short-circuit evaluation for && operator skips the
second operand. I understand your confusion as I have seen this guy's
previous post, but in this case it was just misplaced parentheses ;-)
--
Milosz
"Juan T. Llibre" wrote:
Hi, Milosz,
In that case, what happens if Convert.ToInt32(e.Row.Cells[2].Text = 14) ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:85**********************************@microsof t.com...
Hi Juan,
In this case, "invalid expression term &&" is caused definitely by misplaced
parentheses, because it is a compiler message ;-) (evaluation would be done
at the runtime). Second, bitwise and & operator will give the same result
(apart from the fact short-circuit is not apllicable) because true & true =
true, false & true = false, false & false = false. Therefore, it should be
corrected to:
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
Best regards
--
Milosz
"Juan T. Llibre" wrote:
re:
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
You need to use the "regular" AND operator.
Try :
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
If you use && and e.Row.Cells[2].Text)>=15 is false, e.Row.Cells[2].Text)>=17
is not evaluated (because the result of the AND operation is false no matter what the
value of e.Row.Cells[2].Text)>=17 may be).
This is known as "short-circuit" evaluation...but it requires *both* operands to be true.
In your code, that is not alsways the case.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
<bb****@yahoo.comwrote in message
news:11*********************@e9g2000prf.googlegrou ps.com...
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:C3**********************************@microsof t.com...
Take it easy mate ;-)
<puts down the mouse and walks slowly away from the computer...>
-- http://www.markrae.net
;-)
--
Milosz
"Mark Rae" wrote:
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:C3**********************************@microsof t.com...
Take it easy mate ;-)
<puts down the mouse and walks slowly away from the computer...>
-- http://www.markrae.net
re:
!Take it easy mate ;-)
Has anything I've written implied that I'm not ?
;-)
re:
!his "if" statement could be simplified changed to:
I agree, but the problem, *as stated*, won't be resolved just by changing the parens,
because, if the condition (Convert.ToInt32(e.Row.Cells[2].Text) >= 15) is *false*,
changing the parens won't help him.
He needs to do both what you suggested *and* what I suggested,
if the original conditions remain as stated by him.
Whether he should change his conditions, and not leave them as stated, is another issue.
;-)
re:
!also note he used && therefore there is not point to test the second operand
Again, what if the first operand is false ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:C3**********************************@microsof t.com...
Juan,
Come on, i can't see any logical exlanation in changing && operator to & for
this case :-). First of all, logically, his "if" statement could be
simplified changed to:
if (Convert.ToInt32(e.Row.Cells[2].Text) >= 17)
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
simply because the only numbers that meet both criteria are >= 17. Second,
if the first operand (Convert.ToInt32(e.Row.Cells[2].Text) >= 15) would
return false, second could not be true (logically). Please also note he used
&& therefore there is not point to test the second operand as you're trying
to point out. Third, it was definitely compiler error (syntax error) which
has nothing to do with runtime evaluation.
Take it easy mate ;-)
Best regards
--
Milosz
"Juan T. Llibre" wrote:
>re: !Did you mean if the text in cell equals "14"
Yes.
re: !then statement inside is not going to be reached, simply because the first !condition is false, and short-circuit evaluation for && operator skips the second operand.
That's exactly what I explained...and that's an undesirable "feature". That's why he needs to change the operator.
re: !I understand your confusion
There's no confusion.
He should change both the parens *and* the operator, the first as you suggest; the second as I suggest.
Doing that will cover all the bases for him.
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message news:71**********************************@microso ft.com...
Good morning Juan
Did you mean if the text in cell equals "14"
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
then statement inside is not going to be reached, simply because the first
condition is false, and short-circuit evaluation for && operator skips the
second operand. I understand your confusion as I have seen this guy's
previous post, but in this case it was just misplaced parentheses ;-)
--
Milosz
"Juan T. Llibre" wrote:
Hi, Milosz,
In that case, what happens if Convert.ToInt32(e.Row.Cells[2].Text = 14) ?
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message news:85**********************************@microso ft.com...
Hi Juan,
In this case, "invalid expression term &&" is caused definitely by misplaced
parentheses, because it is a compiler message ;-) (evaluation would be done
at the runtime). Second, bitwise and & operator will give the same result
(apart from the fact short-circuit is not apllicable) because true & true =
true, false & true = false, false & false = false. Therefore, it should be
corrected to:
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
Best regards
--
Milosz
"Juan T. Llibre" wrote:
re: ((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
You need to use the "regular" AND operator.
Try :
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
If you use && and e.Row.Cells[2].Text)>=15 is false, e.Row.Cells[2].Text)>=17 is not evaluated (because the result of the AND operation is false no matter what the value of e.Row.Cells[2].Text)>=17 may be).
This is known as "short-circuit" evaluation...but it requires *both* operands to be true. In your code, that is not alsways the case. Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== <bb****@yahoo.comwrote in message news:11*********************@e9g2000prf.googlegro ups.com...
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
Howdy Juan,
I just wanted to point out that applying & instead of && wouldn't change
anything, because he's had syntax error.
Again, what if the first operand is false ?
I have answered this question already. For both operators (&& and &) you
will get the same result.
1. && operator
Let simplify it
string str = "12";
(Convert.ToInt32(str) >= 15) &&
(Convert.ToInt32(str) >= 17))
cis equivalent to
(12 >= 15) && (12 >= 17)
false && false = false
please note it apllies for shortcirtuit evaluation as well
2. & operator
false & false = false
which is the same result.
As you can see apllying the only difference between && and & for logical
arguments is that bitwise AND does not use short circuit evaluation.
That's why forcing second operand to be evaluated would not change anything
at all.
Hope it is clear now.
Best regards Juan
--
Milosz
"Juan T. Llibre" wrote:
re:
!Take it easy mate ;-)
Has anything I've written implied that I'm not ?
;-)
re:
!his "if" statement could be simplified changed to:
I agree, but the problem, *as stated*, won't be resolved just by changing the parens,
because, if the condition (Convert.ToInt32(e.Row.Cells[2].Text) >= 15) is *false*,
changing the parens won't help him.
He needs to do both what you suggested *and* what I suggested,
if the original conditions remain as stated by him.
Whether he should change his conditions, and not leave them as stated, is another issue.
;-)
re:
!also note he used && therefore there is not point to test the second operand
Again, what if the first operand is false ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:C3**********************************@microsof t.com...
Juan,
Come on, i can't see any logical exlanation in changing && operator to & for
this case :-). First of all, logically, his "if" statement could be
simplified changed to:
if (Convert.ToInt32(e.Row.Cells[2].Text) >= 17)
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
simply because the only numbers that meet both criteria are >= 17. Second,
if the first operand (Convert.ToInt32(e.Row.Cells[2].Text) >= 15) would
return false, second could not be true (logically). Please also note he used
&& therefore there is not point to test the second operand as you're trying
to point out. Third, it was definitely compiler error (syntax error) which
has nothing to do with runtime evaluation.
Take it easy mate ;-)
Best regards
--
Milosz
"Juan T. Llibre" wrote:
re:
!Did you mean if the text in cell equals "14"
Yes.
re:
!then statement inside is not going to be reached, simply because the first
!condition is false, and short-circuit evaluation for && operator skips the second operand.
That's exactly what I explained...and that's an undesirable "feature".
That's why he needs to change the operator.
re:
!I understand your confusion
There's no confusion.
He should change both the parens *and* the operator,
the first as you suggest; the second as I suggest.
Doing that will cover all the bases for him.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:71**********************************@microsof t.com...
Good morning Juan
Did you mean if the text in cell equals "14"
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
then statement inside is not going to be reached, simply because the first
condition is false, and short-circuit evaluation for && operator skips the
second operand. I understand your confusion as I have seen this guy's
previous post, but in this case it was just misplaced parentheses ;-)
--
Milosz
"Juan T. Llibre" wrote:
Hi, Milosz,
In that case, what happens if Convert.ToInt32(e.Row.Cells[2].Text = 14) ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:85**********************************@microsof t.com...
Hi Juan,
In this case, "invalid expression term &&" is caused definitely by misplaced
parentheses, because it is a compiler message ;-) (evaluation would be done
at the runtime). Second, bitwise and & operator will give the same result
(apart from the fact short-circuit is not apllicable) because true & true =
true, false & true = false, false & false = false. Therefore, it should be
corrected to:
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
Best regards
--
Milosz
"Juan T. Llibre" wrote:
re:
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
You need to use the "regular" AND operator.
Try :
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
If you use && and e.Row.Cells[2].Text)>=15 is false, e.Row.Cells[2].Text)>=17
is not evaluated (because the result of the AND operation is false no matter what the
value of e.Row.Cells[2].Text)>=17 may be).
This is known as "short-circuit" evaluation...but it requires *both* operands to be true.
In your code, that is not alsways the case.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
<bb****@yahoo.comwrote in message
news:11*********************@e9g2000prf.googlegrou ps.com...
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
Thanks for clearing that up, Milosz.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:89**********************************@microsof t.com...
Howdy Juan,
I just wanted to point out that applying & instead of && wouldn't change
anything, because he's had syntax error.
>Again, what if the first operand is false ?
I have answered this question already. For both operators (&& and &) you
will get the same result.
1. && operator
Let simplify it
string str = "12";
(Convert.ToInt32(str) >= 15) &&
(Convert.ToInt32(str) >= 17))
cis equivalent to
(12 >= 15) && (12 >= 17)
false && false = false
please note it apllies for shortcirtuit evaluation as well
2. & operator
false & false = false
which is the same result.
As you can see apllying the only difference between && and & for logical
arguments is that bitwise AND does not use short circuit evaluation.
That's why forcing second operand to be evaluated would not change anything
at all.
Hope it is clear now.
Best regards Juan
--
Milosz
"Juan T. Llibre" wrote:
>re: !Take it easy mate ;-)
Has anything I've written implied that I'm not ?
;-)
re: !his "if" statement could be simplified changed to:
I agree, but the problem, *as stated*, won't be resolved just by changing the parens, because, if the condition (Convert.ToInt32(e.Row.Cells[2].Text) >= 15) is *false*, changing the parens won't help him.
He needs to do both what you suggested *and* what I suggested, if the original conditions remain as stated by him.
Whether he should change his conditions, and not leave them as stated, is another issue.
;-)
re: !also note he used && therefore there is not point to test the second operand
Again, what if the first operand is false ?
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message news:C3**********************************@microso ft.com...
Juan,
Come on, i can't see any logical exlanation in changing && operator to & for
this case :-). First of all, logically, his "if" statement could be
simplified changed to:
if (Convert.ToInt32(e.Row.Cells[2].Text) >= 17)
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
simply because the only numbers that meet both criteria are >= 17. Second,
if the first operand (Convert.ToInt32(e.Row.Cells[2].Text) >= 15) would
return false, second could not be true (logically). Please also note he used
&& therefore there is not point to test the second operand as you're trying
to point out. Third, it was definitely compiler error (syntax error) which
has nothing to do with runtime evaluation.
Take it easy mate ;-)
Best regards
--
Milosz
"Juan T. Llibre" wrote:
re: !Did you mean if the text in cell equals "14"
Yes.
re: !then statement inside is not going to be reached, simply because the first !condition is false, and short-circuit evaluation for && operator skips the second operand.
That's exactly what I explained...and that's an undesirable "feature". That's why he needs to change the operator.
re: !I understand your confusion
There's no confusion.
He should change both the parens *and* the operator, the first as you suggest; the second as I suggest.
Doing that will cover all the bases for him.
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message news:71**********************************@microso ft.com...
Good morning Juan
Did you mean if the text in cell equals "14"
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
then statement inside is not going to be reached, simply because the first
condition is false, and short-circuit evaluation for && operator skips the
second operand. I understand your confusion as I have seen this guy's
previous post, but in this case it was just misplaced parentheses ;-)
--
Milosz
"Juan T. Llibre" wrote:
Hi, Milosz,
In that case, what happens if Convert.ToInt32(e.Row.Cells[2].Text = 14) ?
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message news:85**********************************@microso ft.com...
Hi Juan,
In this case, "invalid expression term &&" is caused definitely by misplaced
parentheses, because it is a compiler message ;-) (evaluation would be done
at the runtime). Second, bitwise and & operator will give the same result
(apart from the fact short-circuit is not apllicable) because true & true =
true, false & true = false, false & false = false. Therefore, it should be
corrected to:
if (
(Convert.ToInt32(e.Row.Cells[2].Text) >= 15) &&
(Convert.ToInt32(e.Row.Cells[2].Text) >= 17))
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
Best regards
--
Milosz
"Juan T. Llibre" wrote:
re: ((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
You need to use the "regular" AND operator.
Try :
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
If you use && and e.Row.Cells[2].Text)>=15 is false, e.Row.Cells[2].Text)>=17 is not evaluated (because the result of the AND operation is false no matter what the value of e.Row.Cells[2].Text)>=17 may be).
This is known as "short-circuit" evaluation...but it requires *both* operands to be true. In your code, that is not alsways the case. Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== <bb****@yahoo.comwrote in message news:11*********************@e9g2000prf.googlegro ups.com...
It says invalid expression term &&
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if
((Convert.ToInt32(e.Row.Cells[2].Text)>=15))&&(Convert.ToInt32(e.Row.Cells[2].Text)>=17);
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
}
It says invalid expression term &&
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Deven Oza |
last post by:
Hi every one
can anybody solve this problem for me.
What initial values of a and c are required such that the final values of a and b are:
a = 32
b = 4
…
|
by: Deven Oza |
last post by:
Hi every one
can anybody solve this problem for me.
What initial values of a and c are required such that the final values of a and b are:
a = 32
b = 4
…
|
by: ashokingroups |
last post by:
Hi,
Good morning to all, :-)
One interviewer asked me the following question
He has given the following two tables including data.
DEPT TABLE
-------------------
DEPT(DEPTNO, DNAME, LOC)...
|
by: gsreenathreddy |
last post by:
Hi!
Please solve this query
in employee table in scott user i would like view the details of all the employees (empno, ename )who are working under which manager(mgr) .with his manager name...
|
by: itsvineeth209 |
last post by:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web...
|
by: itsvineeth209 |
last post by:
My task is to create login control without using login control in tools. I shouldnt use sqldatasource or any other. I should use only data sets, data adapters and data readers etc.
U had created...
|
by: fido19 |
last post by:
Once upon a time, there lived a chimpanzee called Luycha Bandor (aka Playboy Chimp).
Luycha was unhappily married to Bunty Mona, a short but cute little lady chimp. Luycha
was tall and handsome –...
|
by: phanimadhav |
last post by:
Hi friends this is my select statement
SELECT user_accountID,Expensive = case quotaAmount
when quotaNo = 'quota1' then sum(quotaAmount) else 0 end
FROM user_accounts
Msg 102, Level 15, State...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |