Eventhandler in dynamically loaded and bound controls

  • Thread starter Christian Robert Schulz
  • 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!
 
L

Lloyd Sheen

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
 
C

Christian Robert Schulz

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top