This issue has me stumped. I have a variable I am sharing in a loop and it is not incrementing.
The variable in question is elrObject.currentLocation. There are two ways to increment it - either if the XML element is empty or if it's not.
Here is the code:
if (reader.Name == "Cell")
{
if (reader.IsEmptyElement)
{
Response.Write("i ran<br>");
elrObject.currentLocation++;
}
else
{
while (reader.Read())
{
if (reader.IsStartElement())
{
//labels
if (elrObject.currentLocation >= elrObject.index && elrObject.currentLocation <= elrObject.index + elrObject.colSpan)
Response.Write("i ran again<br>");
Response.Write(elrObject.currentLocation + "<br>");
elrObject.currentLocation++;
}
if (reader.Name == "Cell")
break;
}
}
}
The output I am getting is:
0
1
2
3
5
The number 4 is when the XML element is empty and the top loop runs. I am incrementing the variable but it won't show me number 4, it skips it entirely and goes to 5. I am sure the upper loop is running properly and before the lower one because the following also runs:
I ran
I ran again
This confirms the upper loop is running before the lower one....yet the number 4 is skipping itself! I would really appreciate some help with this.