0

I'm using .Net 4.5, model binding and currently have a repeater, which contains another repeater.

    <asp:Repeater ID="rptADivisions" runat="server" ItemType="abc.Division" SelectMethod="rptADivisions_GetData">
    <ItemTemplate>
        <div>
            <%#: Item.DivisionName %>
            <asp:Repeater ID="rptDOfficials" runat="server" ItemType="abc.DOfficial" SelectMethod="rptDOfficials_GetData">
                <ItemTemplate>
                    <blockquote>
                        <p><%#: Item.FullName %></p>
                        <small><%#: Item.Position %></small>
                    </blockquote>
                </ItemTemplate>
            </asp:Repeater>
            <hr />
        </div>
    </ItemTemplate>
</asp:Repeater>

I'm able to populate the 1st repeater (rptADivisions), but how would I get the second one to work? I need to have the second one get access to the Did, which is contained in the top repeater (rptADivisions) Item (abc.Divison). I've tried setting the SelectMethod for the second repeater as

public IEnumerable<abc.DOfficial> rptDOfficials_GetData([Control("rptADivisions")] string DidFilter)

but that doesn't seem to work, the DidFilter is always set to null.

Paritosh
  • 4,243
  • 7
  • 47
  • 80

1 Answers1

0

I don't have VS at hand but the repeater, like most databound controls, should have something like DataBound or RowDataBound event you can hook and be able to execute some code when a row is bound to its counterpart from the datasource.

In the event, you should be able to write c# code to access the repeater (FindControl("rptDOfficials")) and get the item you actually bind to. Having these two will allow you to build a set of items and bind declaratively by calling

.DataSource = your set of items
.DataBind()

At least this is how you do nested datagrids, listviews, I hope this works with the repeater too.

Wiktor Zychla
  • 47,367
  • 6
  • 74
  • 106
  • Yes I know about the RowDataBound event, I was trying to see how the SelectMethod would work, playing around with .Net 4.5 and wanted to see if it was possible to do this. – Paritosh May 08 '13 at 20:05
  • 1
    SelectMethod is to databind the top level repeater. I don't think setting this for the nested one will work, at least you have to call DataBind manually. – Wiktor Zychla May 08 '13 at 20:27