c# - Repeater control - how to add to the item template every x rows? -


I have a repeater control outputting some HTML. I want a table that produces 4 columns and then starts a new line (each column will be the next item in the data set).

I can do it with an inline statement:

  <% if ((i + 1)% 4 == 0 and i & gt; 0) {// 5 lines per line% & gt; & Lt; / TR & gt; & Lt;%}% & gt;  

But I can not seem to start within the repeater control. Any ideas?

I am using a repeater control because I have applied paging because the gridview was not appropriate due to the content being displayed.

Depending on what you are doing, you can work with a counter that exists And update it on each loop, to handle the "item data" event of Repeater Control However, determining "last" entry would be a bit more difficult, but it is possible.

However, I think that a more appropriate option for you is to use a datalist instead of a repeater, because the data list automatically render 4 columns and it handles all the HTML rendering for you.


Comments