I have created a Custom Server Control (Inherited from GridView).
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.
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).
So far so good, the textboxes appear, and the filtering is working.
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.
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?