开发者

Is there a similar way to AlternateItemTemplate to do this

开发者 https://www.devze.com 2023-04-09 08:30 出处:网络
I know that with a repeater I can use AlternatingItemTemplate and SeparatorTemplate to adopt a variety of alternating items or for the latter a consistent style / attribute between items.

I know that with a repeater I can use AlternatingItemTemplate and SeparatorTemplate to adopt a variety of alternating items or for the latter a consistent style / attribute between items.

But in my latest task, I require a SeperatorTemplate but only after every 3 items!

I know I c开发者_开发技巧an do this in the ItemDataBound and have a cheeky runningItemCount++ then use runningItemCount % 3 == 0 to place this in.

I also know I can do this using a repeater within a repeater. Just mentioning it is dirty....

I want to keep things clean to be honest, and if it's built in then it's something I want to get in the habit of using, so if anyone knows of how to do so in a nice way (no workarounds please), then please intrigue me.


You are doing this correct, but you can use Container.ItemIndex instead of runningItemCount to keep track of the item index.


Consider to use the ListView control. It support a GroupTemplate and GroupSeparatorTemplate templates.


From looking in to this issue in various areas the conclusion in a nut shell is 'No there isn't'.

I had to use the method I mentioned as unfortunately there is no specific built in feature for this functionality.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号