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

EditForm - User Control

5 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MD
Top achievements
Rank 1
MD asked on 11 Nov 2008, 06:49 PM
Is there a way to obtain a reference to a GridEditFormItem and set public properties of a user control inside of it that is being used as an Edit Form and be able to do so before the user control starts its lifecycle?

Thanks
Matt

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Nov 2008, 07:28 AM
Hello Matt,

Here is an example how to do this in ItemCreated:

if(e.Item is GridEditableItem && e.Item.IsInEditMode)
{
    UserControl userControl=(UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
}

You may need to cast also to your control type.

Kind regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
MD
Top achievements
Rank 1
answered on 12 Nov 2008, 01:55 PM
Thanks for the response, but the problem with doing it at that time is that the user control has already been created and loaded so the Page_Load on the user control has already occured. 

Matt
0
Sebastian
Telerik team
answered on 17 Nov 2008, 12:35 PM
Hi Matt,

Indeed the user control edit form will be initialized inside the ItemCreated event hander of the grid since by that time the controls which will reside in the grid cells are created (see this topic from the documentation for more details). Nevertheless, you can still set the public properties of the WebUserControls custom edit form inside the ItemCreated handler by accessing directly the user control instance as explained by my colleague Vlad.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
MD
Top achievements
Rank 1
answered on 21 Nov 2008, 05:03 PM
Is there a way to programatically assign an instance of a usercontrol so that properties can be set before it is loaded and not just assign the name of the user control through EditFormSettings.UserControlName?
0
Accepted
Vlad
Telerik team
answered on 24 Nov 2008, 07:38 AM
Hi Matt,

You can use FormTemplate instead where you can load/create your user control manually.

Regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
MD
Top achievements
Rank 1
Answers by
Vlad
Telerik team
MD
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or