exBK <ex**@discussions.microsoft.com> wrote:
I am looping through a webcontrol Table and when I hit lets say 30th table
row, I want to append a string to whats already in the 30th row. Not sure
how to do that ... Here's what I have in place ...
int i = 1;
foreach(TableRow r in myTable.Rows)
{
if (i = 30)
{
//append "test:" to what already exists at that row
i=1; //reset i
}
i = i+1;
}
Appreciate your time. TIA.
If you're going to use an index anyway, you might as well not use
foreach:
for (int i=0; i < myTable.Rows.Count; i++)
{
TableRow row = myTable.Rows[i];
if ((i % 30) == 0)
{
// whatever
}
// I assume you're doing something else here?
}
If you're not doing anything else in the loop, you can change it to:
for (int i=0; i < myTable.Rows.Count; i += 30)
{
// whatever
}
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too