J
Jim Weatherly
When adding controls dynamically, make sure the entire
object hierarchy gets rebuilt on postbacks. If the
objects don't get rebuilt because it is a postback,
ASP.Net can't find the event handler for the postback
event. Not sure if this is your issue but it has tripped
me up. In fact, I try to avoid dynamically creating
controls on pages. I would rather drop them on the page in
the designer and set the Visible property to false, and
make them visible from code when appropriate. That way
the controls are always present in the object hierarchy
for the page and event mapping is much easier. However,
the controls always get build when the page gets built, so
it is not without a cost.
object hierarchy gets rebuilt on postbacks. If the
objects don't get rebuilt because it is a postback,
ASP.Net can't find the event handler for the postback
event. Not sure if this is your issue but it has tripped
me up. In fact, I try to avoid dynamically creating
controls on pages. I would rather drop them on the page in
the designer and set the Visible property to false, and
make them visible from code when appropriate. That way
the controls are always present in the object hierarchy
for the page and event mapping is much easier. However,
the controls always get build when the page gets built, so
it is not without a cost.