How to separate repeater data by number of elements

For example, we have 19 elements in the repeater data source. And we wanted to divide them using
5 elements.

Like it

01 02 03 04 05 <br />
06 07 08 09 10 <br />
11 12 13 14 15 <br />
16 17 18 19

How will we do this in the asp.net relay? Thank.

+5
source share
2 answers

Create such a seperator template

<SeperatorTemplate><br /></SeperatorTemplate>

Then you need to bind the ItemDataBound event before you call DataBind () on the repeater. In this case, you look at the item counter and display, when you can divide the number of items by 5, for example:

if (e.Item.ItemType == ListItemType.Seperator)
  e.Item.Visible = ((e.Item.Parent as Repeater).Items.Count % 5 == 0);
+6
source

I would recommend using ListView. It implements the GroupCount property.

+1
source

All Articles