Eventhandler in dynamically loaded and bound controls

  • Thread starter Thread starter Christian Robert Schulz
  • Start date Start date
C

Christian Robert Schulz

Hi there,

in my website I'm buildung the whole page by loading webusercontrols
dynamically using Page.LoadControl("~..."). Within these webusercontrols, I'm
using asp.net controls such as the (old) DataGrid. Since the whole page has
to "rebuild" any time a postback was invoked, i have to rebind the grid any
time before I can react to some of the events that have been fired by a
rowitem like a linkbutton with commandName - so this worked on asp.net 1.1!

After migration to asp.net 2.0, the eventhandlers for the Grid.ItemCommand
doesn't get any events that have been fired by controls that have been
clicked on and initiated the eventhandler.

Do you have any ideas what i can do to get "the old strategy" working?

Thanks a lot!
 
Christian Robert Schulz said:
Hi there,

in my website I'm buildung the whole page by loading webusercontrols
dynamically using Page.LoadControl("~..."). Within these webusercontrols,
I'm
using asp.net controls such as the (old) DataGrid. Since the whole page
has
to "rebuild" any time a postback was invoked, i have to rebind the grid
any
time before I can react to some of the events that have been fired by a
rowitem like a linkbutton with commandName - so this worked on asp.net
1.1!

After migration to asp.net 2.0, the eventhandlers for the Grid.ItemCommand
doesn't get any events that have been fired by controls that have been
clicked on and initiated the eventhandler.

Do you have any ideas what i can do to get "the old strategy" working?

Thanks a lot!

I believe you need to create the controls in the Page_Init. Once you have
done this the page life cycle will get the values from the ViewState and you
should be good to go.

Hope this helps
Lloyd Sheen
 
Hi Lloyd,

thanks for your posting - this gave me the keywords I needed to find some
articles that descriped the changes asp.net 2.0's life- cycle came with.

Unfortunately I wasn't able to change my project in that way (its too
complex after more than 2 years of development) so I decided to implement
some code that workes around that issue and all the postback- stuff.
 
Back
Top