From Shog9:
Incidentally, you may notice a practice in some older questions where answers form a sort of conversation between the person asking the original question and those responding. These generally date back to the early beta period before the comment feature was introduced - it should be avoided now.
I just came across such a question
Here's the conversation
- User posts an answer
I have always recreated my dynamic controls in the LoadViewState event. You can store the number of controls needed to be created in the viewstate and then dynamically create that many of them using the LoadControl method inside the LoadViewState event. In this event you have access to the ViewState but it has not been restored to the controls on the page yet.
- OP responds in an answer (curiously, the user added a comment to that answer days later)
If I dynamically bind the controls there, will ASP.NET automatically handle their state? The problem with doing it in Page_Load is that viewstate is already loaded and it does not add the dynamic controls in the repeater. I would think it would do the same in LoadViewState?
- User responds to the answer in an answer
Yes, the runtime will populate the viewstate of the controls as long as you create the right number of them. The controls' viewstate will populate after this event.
- OP replies in another answer (citing the previous answer)
In what order is LoadViewState called? I added an overridden method signature and it does not seem to be stepping into it.
These two answers, 1 and 2, also look like they might rather be asking for clarification. But I don't know enough about the topic to be sure.
It seems to me that multiple actions are necessary to clean it up, and the tools at my disposal (flags, suggested edits) are not sufficient.
Possibly, #3 could be added to #1 ("The runtime will populate the viewstate of the controls as long as you create the right number of them. The controls' viewstate will populate after this event."). #2 would then no longer be needed and #4 could be turned into a comment to #1. The user's later comment could also be added to #1, maybe as an "Edit:" to show it's a response to the OP's comment.
What to do with a question so old there weren't comments yet and answers form a conversation?