Issue with nesting a gridview in repeater

I am using a Gridview nested in a Repeater to try and represent some data to mimic a simple Excel pivot table. I am stuck at the point of making the pivot table look right because its repeating the tournament name and sub headers.

My code is as follows.
Dim ds As New DataSet()

strSql = "select DISTINCT t.Tournament, t.tournament_id, t.category_name from [dbo].[slam_detail] sd " &
" JOIN dbo.category_detail as t on t.category_id=sd.Category"

Dim daHeader As New SqlDataAdapter(strSql, strConn)
daHeader.Fill(ds, 0)

strSql = "SELECT Task," & plotsStr &
" FROM (Select t.[category_name] as Task,t.[category_id],ppd.Player as Plot, ppd.[Count] " &
" FROM [progress].[dbo].[slam_detail] ppd " &
" JOIN [progress].[dbo].[category_detail] as t on t.[category_id]=ppd.[Category]) SD " &
" PIVOT(max([Count]) " &
" FOR Plot IN (" & plotsStr & ")) AS PVTTable order by Task desc"

Dim daDetails As New SqlDataAdapter(strSql, strConn)
daDetails.Fill(ds, 1)

'relation
Dim rel As New DataRelation("CollectionRelation", ds.Tables(0).Columns("category_name"), ds.Tables(1).Columns("Task"))
ds.Relations.Add(rel)

Repeater1.DataSource = ds.Tables(0).DefaultView
Repeater1.DataBind()

Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
        If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
            DirectCast(e.Item.FindControl("Gridview1"), GridView).DataSource = DirectCast(e.Item.DataItem, DataRowView).CreateChildView("CollectionRelation")
            DirectCast(e.Item.FindControl("Gridview1"), GridView).DataBind()
        End If
End Sub

Open in new window



The source is
    <form id="form1" runat="server">
        <div>
            <table style="width: 100%;">
                <asp:Repeater ID="Repeater1" runat="server">
                    <ItemTemplate>
                        <tr>
                            <td>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("Tournament")%>'></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding-left: 10px">
                                <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="Both" Width="80%">
                                    <AlternatingRowStyle BackColor="White" />
                                    <EditRowStyle BackColor="#2461BF" />
                                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Width="10%" Wrap="false" />
                                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                    <RowStyle BackColor="#EFF3FB" Width="10%"  />
                                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                    <SortedAscendingCellStyle BackColor="#F5F7FB" />
                                    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                                    <SortedDescendingCellStyle BackColor="#E9EBEF" />
                                    <SortedDescendingHeaderStyle BackColor="#4870BE" />
                                </asp:GridView>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </table>
        </div>
        <asp:Button ID="Button1" runat="server" Text="Player Progress" />
    </form>

Open in new window


Here is a comparison of the ASP.NET and Excel result;

Results comparisonI have attached the data in Excel in case you want to reproduce the issue.
slam-data.xlsx
LVL 1
David CIT Projects ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Randy DownsOWNERCommented:
Maybe this will help. It looks like you want to group by the event (Wimbledon, US Open).

A recurring requirement not available in the GridView is to create groups and summaries. To create summaries we can easily code the RowDataBound event. Grouping is a more complex task, and involves more coding and debugging. But when we need to combine these two features the things really start to get messy. With this in mind I have implemented the GridViewHelper, as the name suggests, a helper class to aid the creation of groups and summaries.
David CIT Projects ManagerAuthor Commented:
Hi, I ended up using the NReco.PivotData library and it did exactly what I wanted with minimal code

http://www.nrecosite.com/pivot_data_library_net.aspx

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David CIT Projects ManagerAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.