我正在使用一个asp.net中继器来创建一堆图像.图像标记是一样的,因此标准< ItemTemplate>好的
但是,我想将K图像包裹在div中.让我说我绑定25图像到中继器,我想要5个图像每个div.如何有条件地创建div的开始和关闭标签?
这是一个更适合for循环的情况.
解决方法
这应该适用于你,不需要代码中的任何东西(除了绑定中继器..):
<asp:Repeater ID="repImages" runat="server"> <HeaderTemplate><div></HeaderTemplate> <ItemTemplate> <%# (Container.ItemIndex != 0 && Container.ItemIndex % 5 == 0) ? @"</div><div>" : string.Empty %> <asp:Image ID="imggallery" runat="server" ImageUrl='<%# /* your code here */ %>' /> </ItemTemplate> <FooterTemplate></div></FooterTemplate> </asp:Repeater>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。