ASP.NET Repeater Template, Conditional Code for every Nth element

后端 未结 4 846
梦毁少年i
梦毁少年i 2021-02-13 13:34

I\'m using an asp.net repeater to create a bunch of images. The image markup is all the same so the standard is fine.

However, I want

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-13 13:56

    If you want to keep your markup on the ASPX page you could also try this variation on David's method:

    On the aspx page:

    
    
    
    
    
    

    In the ItemDataBound event in the codebehind:

    e.Item.FindControl("divStart").Visible
        = e.Item.FindControl("divEnd").Visible 
        = e.Item.ItemIndex % 5 == 0;
    

提交回复
热议问题