我有一个数据源,每行包含日期项目.这些将被绑定到转发器并按日期排序.我想在渲染时将每个月作为单独的表格呈现,但有没有办法使用转发器控件执行此操作,而无需从服务器端代码动
理想情况下,我想要以下内容:
Examples Data: Row 1: Title 1, 01/12/2009 Row 2: Title 1, 02/12/2009 Row 1: Title 1, 01/01/2010 Row 1: Title 1, 02/01/2009 Required output: Dec 09 ------------------------------- Title | Date | -------------------------------| Title1 | 01/12/2009 | -------------------------------| Title2 | 02/12/2010 | -------------------------------| Jan 10 ------------------------------- Title | Date | -------------------------------| Title1 | 01/01/2010 | -------------------------------| Title2 | 02/01/2010 | -------------------------------|您可以在ItemTemplate中使用PlaceHolder控件来包含重复的goup页眉和页脚.然后根据日期设置PlaceHolders在OnItemDataBound或OnItemCreated事件处理程序中的可见性.像这样:
<ItemTemplate>
<asp:PlaceHolder id="table_end" visible="<%# _newMonthStarting && (!_firstMonth) %>" runat="server">
</table>
</asp:PlaceHolder>
<asp:PlaceHolder id="table_end" visible="<%# _newMonthStarting %>" runat="server">
<div><%# _monthHeader</div>
<table>
<tr>
<th>Title</th>
<th>Date</th>
</tr>
</asp:PlaceHolder>
<tr>
<td><!-- data --></td>
<td><!-- data --></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
