ASP.NET Loading a User Control in a Repeater
        Posted  
        
            by user70192
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user70192
        
        
        
        Published on 2010-03-23T01:03:09Z
        Indexed on 
            2010/03/23
            1:11 UTC
        
        
        Read the original article
        Hit count: 372
        
ASP.NET
Hello,
I have a Repeater control that loads instances of a custom control I have built. This repeater looks like this:
<asp:Repeater ID="myRepeater" runat="server" OnLoad="myRepeater_Load">
  <HeaderTemplate>
    <table border="0" cellpadding="0" cellspacing="0">
  </HeaderTemplate>
  <ItemTemplate>
    <tr><td><my:CustomControl ID="myControl" runat="server" 
      OnLoad="myControl_Load" />
    </td></tr>
  </ItemTemplate>
  <FooterTemplate>
    </table>
  </FooterTemplate>
</asp:Repeater>
I bind to the Repeater through the myRepeater_Load event handler. My custom control is used to render an item within the Repeater. Because of this, I am trying to set properties on the custom control during the myControl_Load event handler. However, I do not know how to access the current item during the myControl_Load event.
Is there a way I can pass along the current item or access the current item during the myControl_Load event? If so, how?
Thank you,
© Stack Overflow or respective owner