views:

557

answers:

1

I have a repeater control outputting some HTML. I want a table which outputs 4 columns and then start a new row (each column will be the next item in the data set).

I can do this with inline statements:

<%  if ((i + 1) % 4 == 0 && i > 0)
                { //5 items per row%>
            </tr>
            <% } %>

But I can't seem to initialise i within the repeater control. Any ideas?

I am using a repeater control because I have implemented pagination as a gridview was not appropriate due to how I am displaying the content.

+1  A: 

Depending on exactly what you are looking at doing you could work with a counter that exists and update it on every loop, handling the "ItemDataBound" event of the repeater control. However, determining the "last" entry will be a bit more difficult, but possible.

However, I think a more appropriate option for you is to use a DataList rather than a repeater, as the data list can automatically render 4 columns and it will handle all of the HTML rendering for you.

Mitchel Sellers