I have a control (say, a DataGrid or a ComboBox) which is a child of a user control. I want to DataBind it on every request, rather than have it's state persist through ViewState. I need to leave EnableViewState=true
however. This means, I think, that I need to call DataBind before TrackViewState() is called.
I read the fantastic blog post TRULY Understanding ViewState and it answers my question in 4. Initializing child controls programmatically
. However, the article's solutions are less-than-ideal: create child controls dynamically (I'm not and can't -- too much existing code), use a 3rd party CodeExpressionBuilder (would much prefer this was in code-behind), and use OnPreInit (which "doesn't help you what-so-ever if you are developing a CONTROL").
Since that article is rather old (circa 2006) I was hoping that newer versions of ASP.NET rectify the situation such that there are better solutions now. So, community, are there any GOOD ways to do this?