【发布时间】:2010-10-25 06:30:18
【问题描述】:
我试图在我的 <itemtemplate/> 的备用行上简单地添加一个 css 类到一个 div 中,而不需要包含一个完整的 <alternatingitemtemplate/> 的开销,这将迫使我保持大量标记同步未来。
我已经看到了诸如 http://blog.net-tutorials.com/2009/04/02/how-to-alternate-row-color-with-the-aspnet-repeater-control/ 之类的解决方案,我很想使用它,但这对我来说仍然没有“味道”。
还有其他人有更易于维护和更直接的解决方案吗?理想情况下,我希望能够执行以下操作:
<asp:repeater id="repeaterOptions" runat="server">
<headertemplate>
<div class="divtable">
<h2>Other Options</h2>
</headertemplate>
<itemtemplate>
<div class="item <%# IsAlternatingRow ? "dark" : "light" %>">
但我不知道如何实现IsAlternatingRow - 即使使用扩展方法。
【问题讨论】:
标签: c# asp.net data-binding extension-methods repeater