I just wanted to publish the reason for the dynamic controls
problem that I was having, which I have now come to understand.
Basically, the problem is that in each request/response sequence, the ViewState was getting out of sync with the control tree. To see the problem again, you can download this small project
, run it and click the Update button on the front tab. You will notice two things. The text in the control above it disappears and the event handler which I hooked up to that update button does not get hit.
I have been able to prove my theory with code, which you can download in this project
. That project manually reconstructs the relationship between ViewState and the control tree. Note: I would never implement the functionality using code like that, as it was just an academic exercise to understand exactly what was going on with those dynamic controls. It also explains why Dimitar's proposed solution works. You will see in that version of the code that the Update button does hit its handler, when clicked.
I hope this helps others in their understanding of the complex relationship between ViewState, dynamic controls and the control tree.