Events not firing (First time only) in a dynamic user control. Please help.

G

Guest

I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle.

1) MainPage_load
2) User control1_Load

user clicks a dropdown in UC1
_________________________

1) MainPage_Load
2) User Control_1 Load
3) dropdown__SelectedIndexChanged in User control1:
sends a 'Report Changed' event to main page.
4) MainPage_ReportChanged : Loads_Report User control
sends a 'Create Report' event to newly loaded control and saves report name in view state.
5) Report_UserControl_Load
6) Report_UserControl: Create Report (Populates a datagrid etc.)

Userclicks a button control on Report User control:
_____________________________________
1) Main Page_Load
2) User Control_1 Load
3) Report User Control Load ( Main page dynamically loads this control by looking at the report name saved in view state)

PROBLEM:< ReportUserControl_Button control event does NOT get fired >

User clicks on button control on Report User Control:
___________________________________________
1) Main Page_Load
2) User Control_1 Load
3) Report User Control Load ( Main page dynamically loads this control by looking at the report name saved in view state)

ReportUserControl_Button control event gets fired


----- Shourie wrote: -----

Hi all,

I'm creating a reporting application, which is primarily a webpage with two user controls. One user control has a drop down with report names and other selection criteria controls needed for the report.
whenever the selection changes in the Report dropdown in the first user control, it sends a custom event to to the main page with the report name,selection criteria as eventargs.
The main page in turn loads the appropriate usercontrol for that report and sends another custom event to that usercontrol to create a report which typically has a datagrid.

So far so good,but when I click on a commandbutton in the datagrid, the ItemCommand fire does not fire for the first time but starts working from the second click.

I can see that binding the datagrid after the 'Report User controls Page_Load' (by way of handling an event from main page ) may be causing the event to not fire. However my requirement is also that I dynamically load the report control first and load its data. Greatly appreciate if any of you can show some direction on how I might be able to solve this design issue.

Thanks,
-Shourie


----- Shourie wrote: -----

Hi all,

I'm creating a reporting application, which is primarily a webpage with two user controls. One user control has a drop down with report names and other selection criteria controls needed for the report.
whenever the selection changes in the Report dropdown in the first user control, it sends a custom event to to the main page with the report name,selection criteria as eventargs.
The main page in turn loads the appropriate usercontrol for that report and sends another custom event to that usercontrol to create a report which typically has a datagrid.

So far so good,but when I click on a commandbutton in the datagrid, the ItemCommand fire does not fire for the first time but starts working from the second click.

I can see that binding the datagrid after the 'Report User controls Page_Load' (by way of handling an event from main page ) may be causing the event to not fire. However my requirement is also that I dynamically load the report control first and load its data. Greatly appreciate if any of you can show some direction on how I might be able to solve this design issue.
 
G

Guest

I found the solution. I need to just set the IDs of the dynamically user controls for the events to fire.
Strange.(I'm even loading the usercontrol in the same function ).
Can any one throw light on why the ID is needed for the dynamic user control ?

Regards,
Shourie

----- Shourie wrote: -----

I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle.

1) MainPage_load
2) User control1_Load

user clicks a dropdown in UC1
_________________________

1) MainPage_Load
2) User Control_1 Load
3) dropdown__SelectedIndexChanged in User control1:
sends a 'Report Changed' event to main page.
4) MainPage_ReportChanged : Loads_Report User control
sends a 'Create Report' event to newly loaded control and saves report name in view state.
5) Report_UserControl_Load
6) Report_UserControl: Create Report (Populates a datagrid etc.)

Userclicks a button control on Report User control:
_____________________________________
1) Main Page_Load
2) User Control_1 Load
3) Report User Control Load ( Main page dynamically loads this control by looking at the report name saved in view state)

PROBLEM:< ReportUserControl_Button control event does NOT get fired >

User clicks on button control on Report User Control:
___________________________________________
1) Main Page_Load
2) User Control_1 Load
3) Report User Control Load ( Main page dynamically loads this control by looking at the report name saved in view state)

ReportUserControl_Button control event gets fired


----- Shourie wrote: -----

Hi all,

I'm creating a reporting application, which is primarily a webpage with two user controls. One user control has a drop down with report names and other selection criteria controls needed for the report.
whenever the selection changes in the Report dropdown in the first user control, it sends a custom event to to the main page with the report name,selection criteria as eventargs.
The main page in turn loads the appropriate usercontrol for that report and sends another custom event to that usercontrol to create a report which typically has a datagrid.

So far so good,but when I click on a commandbutton in the datagrid, the ItemCommand fire does not fire for the first time but starts working from the second click.

I can see that binding the datagrid after the 'Report User controls Page_Load' (by way of handling an event from main page ) may be causing the event to not fire. However my requirement is also that I dynamically load the report control first and load its data. Greatly appreciate if any of you can show some direction on how I might be able to solve this design issue.

Thanks,
-Shourie


----- Shourie wrote: -----

Hi all,

I'm creating a reporting application, which is primarily a webpage with two user controls. One user control has a drop down with report names and other selection criteria controls needed for the report.
whenever the selection changes in the Report dropdown in the first user control, it sends a custom event to to the main page with the report name,selection criteria as eventargs.
The main page in turn loads the appropriate usercontrol for that report and sends another custom event to that usercontrol to create a report which typically has a datagrid.

So far so good,but when I click on a commandbutton in the datagrid, the ItemCommand fire does not fire for the first time but starts working from the second click.

I can see that binding the datagrid after the 'Report User controls Page_Load' (by way of handling an event from main page ) may be causing the event to not fire. However my requirement is also that I dynamically load the report control first and load its data. Greatly appreciate if any of you can show some direction on how I might be able to solve this design issue.
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top