473,405 Members | 2,261 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,405 software developers and data experts.

Why is this condition true when it should be false ?

This code, for a page control, is supposed to print a gif (for
each new year, followed by the text of each year). It doesn't do
that. It is just a simplified version of another control used
for demonstration that has the same bug.
1) The <HeaderTemplate> displays the 2004 gif and sets the value
of sPubYY = 2004.

2) When the <ItemTemplate> code executes sPubYY has been set =
2004 (by the <HeaderTemplate> above).

So the initial condition ( Container.DataItem <> sPubYY ) should
be False (because Container.DataItem = 2004 and sPubYY = 2004).
But this condition is True, so the 2004 gif is output again.

I can't understand why this should happen, because sPubYY should
not change value after the <HeaderTemplate> code executes.

How can I display the gif for 2004 (using the <HeaderTemplate>)
but not display it in the <ItemTemplate>?

Please don't suggest the obvious (that I ditch the
<HeaderTemplate>). I need to show the first gif in a slightly
different way to the others.

PS: view state for this control is set to off because the real
control displays a vast amount of data from a dataReader.

+++ +++ +++ +++

<Script Runat="Server">
Public sPubYY As Integer

Sub Page_Load( s As Object, e As EventArgs )
Dim aryDates() As Integer =
{2004,2004,2003,2003,2002,2002,2002,2001,2000,1999 }
rptArchive.DataSource = aryDates
rptArchive.DataBind()
End Sub

Function NewYear( yyyy As Integer ) As String
sPubYY = yyyy
Return " <p class='linebelow'><img src= 'images/arc_" &
sPubYY & ".gif' width='120' border='0' alt='" & sPubYY &
"'></p>"
End Function

</Script>

<asp:Repeater
ID="rptArchive"
Runat="Server">
<HeaderTemplate>
<%=NewYear(2004) %>
</HeaderTemplate>

<ItemTemplate>
<%# "Container.DataItem = " & Container.DataItem & "<br>" %>
<%="sPubYY = " & sPubYY & "<br>" %>
<%# "Container.DataItem <> sPubYY = " & (Container.DataItem <>
sPubYY) & "<br>" %>

<%# IIf( Container.DataItem <> sPubYY,
NewYear(Container.DataItem), "") %>
<h4><%# Container.DataItem %></h4>
</ItemTemplate>
</asp:Repeater>

+++ +++ +++ +++
I've included these 3 lines just to illustration variable values

<%# "Container.DataItem = " & Container.DataItem & "<br>" %>
<%="sPubYY = " & sPubYY & "<br>" %>
<%# "Container.DataItem <> sPubYY = " & (Container.DataItem <>
sPubYY) & "<br>" %>

+++ +++ +++ +++

Nov 18 '05 #1
0 1102

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

Similar topics

6
by: SB | last post by:
This while loop keeps repeating even when a correct character is entered.... cout<<endl<<"What day would you like to schedule the appointment?"<<endl; cout<<endl<<"Enter 'M' for Monday, 'T' for...
12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
19
by: Jordan | last post by:
Let me just start by saying I'm a very accomplished ASP programmer. I need to rely on that becuase this error boggles the mind. Just today, I had to troubleshoot an error in one of my...
3
by: Ben | last post by:
Hi There I am doing some unit testing at the moment, and the majority of the leg work involves taking two objects (expected vs actual) and verifying that their properties are equal. The objects...
4
by: joh12005 | last post by:
Hello, i posted for suggestions a little idea even if it still needs further thoughts but as i'm sure you could help :) if would like to implement some kind of Condition class which i coud...
30
by: Jake Forson | last post by:
Hi there, Before I notify MSFT, can someone confirm this is in fact a compiler bug (it seems pretty obvious but I'm fairly new to C#). The following code (erroneously) generates compiler error...
14
by: bbawa1 | last post by:
It says invalid expression term && protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if...
3
by: mekonnen lemessa | last post by:
Can you help me in converting a code written in VB5 into VB6? Also can you provide me any source book which compares VB5 and VB6? The source code to be converted into VB6 will be as follows: VERSION...
2
by: waltbrad | last post by:
The script comes from Mark Lutz's Programming Python. It is the second line of a script that will launch a python program on any platform. import os, sys pyfile = (sys.platform == 'win' and...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.