Bind Repeater to OnInit .
http://codinglifestyle.wordpress.com/2009/10/08/repeaters-and-lost-data-after-postback-viewstate/
Change I assume that you are handling the UserControl Load event, which receives the Page Load event after . Dynamic controls must be created in Page_Load no later than.
http://forums.asp.net/t/1191194.aspx
Thus, either bind the repeater to Page_Init, or -that I would recommend:
Provide a public function, such as BindData , that can be called from your page load event. This is also recommended since the page is a UserControl.
public void BindData() { var products = (from p in context.Products select p).Take(30); rptProducts.DataSource = products; rptProducts.DataBind(); }
source share