title: Data binding and user controls
body: <p>This is really bugging me, so I hope someone can help me a bit</p>
  
  <p><br></p>
  
  <p>1) Assuming page contains user control, then <em>Page.Page_Load</em> is fired prior to <em>UserControl.Page_Load</em>:</p>
  
  <p><br>
  a) I assume that if Page contains <em>ObjectDataSource1</em> control, then <em>ObjectDataSource1</em> will perform data binding prior to <em>UserControl.Page_Load</em>?! </p>
  
  <p><br>
  b) If that is the case, then does <em>Page.Prerender</em> also happen prior to <em>UserControl.Page_Load</em>? </p>
  
  <p><br>
  c) If <em>UserControl</em> contains <em>ObjectDataSource2</em> control, will this control perform data binding at the same time as <em>ObjectDataSource1</em> (which is contained directly inside <em>Page</em>)?</p>
  
  <ul>
  <li><p>But that wouldn’t make much sense, since I would assume controls inside <em>UserControl</em> follow <em>UserControl’s</em> life cycle and not <em>Page’s</em>?!</p></li>
  <li><p>Anyhow, I thought that web page hosting user control can’t receive events or call methods of controls contained inside user control?!If so, then how is web page able to call databind on <em>ObjectDataSource2</em>? </p></li>
  </ul>
  
  <p><br></p>
  
  <p>thanx</p>
  
  <p><br></p>
  
  <p>EDIT:</p>
  
  <p>The main source of my confusion is the following quote from some book:</p>
  
  <blockquote>
    <p>…user's country, state and city are read only once from the profile and saved in local variables. UserControl.Page_Load cannot be used for this because automatic binding done by the UserControl.ObjectDataSource happens earlier, so we have to use the UserControl.Page_Init event handler</p>
  </blockquote>
  
  <p>I assume in the above quote author suggests that if user control contains ODS, then this ODS will perform data binding prior to UserControl.Page_Load, which is not what you've stated?</p>
  
  <p>BTW - user control the above quote is talking about is added to web page at design time</p>
  
  <p><br></p>
  
  <p>ANOTHER EDIT:</p>
  
  <p>I did some googling and the book(or part of it) is available at the following link.</p>
  
  <p><em><a href="http://books.google.com/books?id=hziE1NB0UkIC&amp;printsec=frontcover&amp;dq=website+programming+asp.net+2.0+design+solution&amp;ei=7lmESv63Npu-ygTO0f2yDg#v=onepage&amp;q=&amp;f=false" rel="nofollow noreferrer">http://books.google.com/books?id=hziE1NB0UkIC&amp;printsec=frontcover&amp;dq=website+programming+asp.net+2.0+design+solution&amp;ei=7lmESv63Npu-ygTO0f2yDg#v=onepage&amp;q=&amp;f=false</a></em></p>
  
  <p>Anyways, the quote is taken from page 257, which is basically a part of a section describing <em>ArticleListing.ascx</em> user control.  </p>
  
  <p>BTW – just so you won’t think I’m delusional … I don’t expect anyone to read the whole section on that user control, I just thought that perhaps code on page 257 would provide sufficient context to figure out what author actually meant </p>