M
Mark Olbert
I'm running into a well-described issue in the ASPNET model that I haven't found a good work around for.
I have a GridView to which I dynamically add data-bound TemplateFields at run-time. The specific fields that are added depend on the
state of the application.
The contents of these fields displays properly after they are first initialized, but not after postback (e.g., just a simple button
control that doesn't do anything except trigger the postback). This is the well-described issue -- it's apparently due to the fact
that they dynamically added controls must be recreated in the page life cycle before the point where viewstate is loaded.
My problem is that the specific controls that are added depend on the >>state<< of the application...which is itself stored in
viewstate (well, actually controlstate, but for this discussion I don't think that should matter).
So I think I have a chicken-and-egg situation: I have to recreate the dynamically-added TemplateFields >>before<< viewstate is
loaded, but I don't know which TemplateFields to add until >>after<< viewstate is loaded.
I hope that's a reasonably clear description of the problem/issue. Is there an approach that lets me resolve this conundrum? Is
there a way to load or examine viewstate/controlstate "early"?
- Mark
I have a GridView to which I dynamically add data-bound TemplateFields at run-time. The specific fields that are added depend on the
state of the application.
The contents of these fields displays properly after they are first initialized, but not after postback (e.g., just a simple button
control that doesn't do anything except trigger the postback). This is the well-described issue -- it's apparently due to the fact
that they dynamically added controls must be recreated in the page life cycle before the point where viewstate is loaded.
My problem is that the specific controls that are added depend on the >>state<< of the application...which is itself stored in
viewstate (well, actually controlstate, but for this discussion I don't think that should matter).
So I think I have a chicken-and-egg situation: I have to recreate the dynamically-added TemplateFields >>before<< viewstate is
loaded, but I don't know which TemplateFields to add until >>after<< viewstate is loaded.
I hope that's a reasonably clear description of the problem/issue. Is there an approach that lets me resolve this conundrum? Is
there a way to load or examine viewstate/controlstate "early"?
- Mark