Problem with loading UserControls dynamically.

  • Thread starter Thread starter Sundaresan
  • Start date Start date
S

Sundaresan

I've a form where I load two user controls dynamically.

User Control-1 has a no.of dropdowns and based on the
selection I typically
populate a datagrid in the user control-2,

Also the I could be loading a different usercontrol-2
based on the selections in usercontrol-1.

Also I thought of passing the selection values through
public properties of the usercontrols without
resorting to querystrings or session variables.

So I've decided to load the UserControl-1 in Page_Load and
Load UserControl-2 in Page_Prerender
So that the postback on usercontrol-1 is processed and the
properties of usercontrol-2 are set
properly before it loads.

This works just fine, until I've a requirement where I
need to post back from the datagrid in user_control2.
Those events just won't fire ( probably because I'm always
loading the usercontrol-2 in PreRender ).

On the other hand, If I try to load both user controls in
page load, UserControl-2 would not know any thing
about the usercontrol-1's server controls Current
selection.

Can some one straighten out this design problem for me ?
Appreciate your help.

-Sundar
 
Back
Top