Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Simple question, not sure there's a simple answer!

So here's the code: (I've simplified it a lot to make it easier to read)

<asp:Repeater runat="server>
    <ItemTemplate>
        <asp:Repeater runat="server">
            <HeaderTemplate>
                <h1>My header here for: <%# OuterContainer.DataItem.MyItemName %> </h1>
            </HeaderTemplate>
            <ItemTemplate>
                My items code here
            </ItemTemplate>
        </asp:Repeater>
    </ItemTemplate>
</asp:Repeater>

How, in the HeaderTemplate - can I access the DataItem in the parent repeater?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
471 views
Welcome To Ask or Share your Answers For Others

1 Answer

I have found the answer actually:

Use:

<HeaderTemplate>
    <%# ((RepeaterItem)Container.Parent.Parent).DataItem %>
</HeaderTemplate>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...