For example, we have 19 items on the repeater datasource. And we wanted to separate them using
by 5 items.It'开发者_开发知识库s like
01 02 03 04 05 <br />
06 07 08 09 10 <br />
11 12 13 14 15 <br />
16 17 18 19
How are we going to do this in asp.net repeater? Thanks.
Create a seperator template like so
<SeperatorTemplate><br /></SeperatorTemplate>
Then you have to bind ItemDataBound event before you call DataBind() on the repeater. In this event you look at the item count and display seperator when you can divide the item count by 5, like so:
if (e.Item.ItemType == ListItemType.Seperator)
e.Item.Visible = ((e.Item.Parent as Repeater).Items.Count % 5 == 0);
I'd recommend using the ListView. It implements a property called GroupCount.
精彩评论