title: ASP.NET Custom Server Control (GridView), DataBinding, and Control Lifecycle conflict
body: <p>I have created a Custom Server Control (Inherited from GridView).</p>
  
  <p>On the page, the GridView is DataBound to a DataSet, so I do not know at design time what columns will be present in my GridView.</p>
  
  <p>Now, what I want to do is, to add a textbox in every Cell for the GridView Header row, and those textboxes will control column filtering. (textboxes are added using the GridView OnRowCreated method).</p>
  
  <p>So far so good, the textboxes appear, and the filtering is working.</p>
  
  <p>Problem is, after every postback, the Text value of the textboxes is lost. From my experimentations, this seems to be because I'm adding the textboxes too late in the Page/Control lifecycle.</p>
  
  <p>How does one deal with this type of problem, where I would need to create and add the textboxes early in the Lifecycle (like, the GridView's OnInit), but adding the textboxes is dependant on information that is obtained later in the lifecycle?</p>