Eventhandler in dynamically loaded and bound controls
am 17.01.2008 19:40:01 von ChristianRobertSchulz
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!
Re: Eventhandler in dynamically loaded and bound controls
am 17.01.2008 20:25:21 von Courtney
"Christian Robert Schulz"
wrote in message news:A1857C57-7670-43E8-97CF-5C83736012D6@microsoft.com...
> 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
Re: Eventhandler in dynamically loaded and bound controls
am 21.01.2008 15:42:03 von ChristianRobertSchulz
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.
"Lloyd Sheen" wrote:
> 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
>
>