Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 27th, 2007, 08:31 PM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Default Nested Repeaters, need inner rptr to know which...

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested Repeaters darylh2004 ASP.NET 2.0 Basics 0 July 6th, 2006 04:14 AM
Nested Repeaters three deep? Silfverduk ASP.NET 2.0 Basics 0 June 21st, 2006 01:14 PM
Nested Repeaters to create hierarchy Lord__Chaos ASP.NET 2.0 Basics 0 May 26th, 2006 12:37 PM
dynamic menu from nested repeaters Jacko ASP.NET 1.0 and 1.1 Professional 1 March 6th, 2006 06:51 AM
master/detail pages with Repeaters ben21 Classic ASP Basics 0 September 19th, 2005 06:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.