ASP.NET Repeater Template, Conditional Code for every Nth element
问题 I'm using an asp.net repeater to create a bunch of images. The image markup is all the same so the standard <ItemTemplate> is fine. However, I want to wrap K images in a div. Lets say I bind 25+ images to the repeater and I want 5 images per div. How do I go about conditionally creating the start and close tags for the div? Is this a case better suited for a for loop. 回答1: This should work for you, with no need for anything in the code behind (other than binding the repeater..): <asp:Repeater