I think there is some redundancy in the variables startrow,
pagestop, maxrows, block and rowcount, and that the redundancy
makes the logic unclear. For example, the statement
StartRow = MaxRows * StartRow + 1 doesn't make sense.
Is the code I give below of any help? In any case, I would
advise you do everything on a single page, rather than redirect.
You don't have to read the tag every time, do you?