Asp net aspx page and webcontrol issue

Posted by Josemalive on Stack Overflow See other posts from Stack Overflow or by Josemalive
Published on 2010-04-14T09:34:52Z Indexed on 2010/04/14 9:53 UTC
Read the original article Hit count: 370

Filed under:
|

Hello,

I have a class that inherits from Page, called APage.

public abstract class APage: Page
{
  protected Repeater ExampleRepeater;
  ....
  protected override void OnLoad(EventArgs e)
  {
        if (null != ExampleRepeater)
        {
                ExampleRepeater.DataSource = GetData();
                ExampleRepeater.DataBind();
        }
        base.OnLoad(e);
  }
}

For other hand i have an aspx page called Default that inherits from this APage:

public partial class Default : APage
{

}

on the design part of this Default page, i have a repeater:

<asp:Repeater ID="ExampleRepeater" runat="server">
    <ItemTemplate>
        <%# DataBinder.Eval(Container.DataItem, "Name") %><br/>
    </ItemTemplate>
</asp:Repeater>

This repeater is datasourced at the base APage load event, but at this level this web control is null.

Do you have any idea why the control is null in the base page?

Thanks in advance.

Best Regards.

Jose.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about webforms