I want to display a table that has report groups (the parent item) and reports (the child item), and I want the table row background color to alternate independently...in other words I don't want to start over my alternating of bgcolor on each group, I want it to just alternate on each row of the table.
My problem is nesting repeaters isn't working for me. The inner repeater doesn't "know" whether it is on the parent repeaters ItemTemplate or AlternateItemTemplate so it isn't able to determine which bgcolor to use on the rows that it prints out.
Here is the code I have now. The problem is when a group has an even number of reports, the next group title row is printed with the same bgcolor as the last report row, which looks like crap. This seems like a very simple issue yet I don't know how to manipulate the provided repeater control to achieve it.
Code:
<asp:Repeater ID="rptrReportGroups" runat="server"
DataSourceID="ObjectDataSource1">
<HeaderTemplate>
<table cellspacing="0" cellpadding="3">
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color: #EBF3F7;">
<td colspan="2"><b><%# Eval("Name") %></b></td>
</tr>
<asp:Repeater ID="rptrReports" runat="server"
DataSource="<%# CType(Container.DataItem, StandardReportGroup).Reports %>">
<ItemTemplate>
<tr style="background-color: #FFF;">
<td><%# Eval("Code") %></td>
<td><%# Eval("Title") %></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #EBF3F7;">
<td><%# Eval("Code") %></td>
<td><%# Eval("Title") %></td>
</tr>
</AlternatingItemTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetAll"
DataObjectTypeName="Veris.BusinessObject.StandardReportGroup"
TypeName="Veris.BusinessObject.StandardReportGroup">
</asp:ObjectDataSource>
My current work around is to create a table in the code behind and add rows as needed there. This was very simple but doesn't take advantage of the provided Repeater control and it is irritating me that I don't know how to do this.
Any help is greatly appreciated! Thanks in advance for your time.
Neil
Neil Timmerman
Programmer
Veris Consulting