This is a migrated thread and some comments may be shown as answers.

Edit Template control events in dynamic user control

1 Answer 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jayvr
Top achievements
Rank 1
jayvr asked on 19 May 2008, 01:50 PM
Hello,

      I have a grid in a dynamically generated user control. The user control is generated in a content page. I have buttons and a dropdown that are displayed in EditItemTemplate when the form is in EditMode. I have tried to attach event handlers for the buttons and the indexchange event of the dropdown but it is not working. I am putting the event handlers in the code behind of the user control. I want to try to put the event handlers in the code behind of the content page but how can I know when the grid is in edit mode when I am in the content page. Also, how would I access the controls in the EditItemTemplate from the content page? Do you have some sample code that does this? Any ideas would help.

Thanks,
Jayvr

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 22 May 2008, 07:07 AM
Hi jayvr,

As a first step I suggest you verify that you load the user control (holding the grid instance) programmatically in par with the conventions depicted in this documenation topic. This will ensure that the viewstate of the user control (and the controls residing in it) will remain consistent and their event lifecycle will be intact.

Additionally, if you attach the event handlers for the buttons/dropdown programmatically, confirm that you do that no later than the PageLoad stage of the user control lifecycle.

To access the controls from the EditItemTemplate of your template column, intercept the ItemCreated or ItemDataBound event of the grid and reference the relevant control invoking the e.Item.FindControl(ctrlId) method where ctrlId is the id of this control.

Further detail about the major differences between the ItemCreated and ItemDataBound events you can find in this resource.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
jayvr
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or