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

Which event occurs when EditForm is shown?

2 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jaime
Top achievements
Rank 1
Jaime asked on 20 Oct 2008, 09:07 PM
Hello..

I have a custom template edit form. The problem I have is that the edit form has a field that is required only when inserting a record. When editing a record it is optional.

I have a required field validator that I want to enable or disable depending if the form is shown in insert or edit mode.

To accomplish it, I need to know if there is an event I can implement where I can enable or disable the validator. I tried using EditCommand or ItemCommand (with "InitInsert" verification) but in both cases the edit form isn't accesible.

Any help will be greatly appreciated

Thanks
Jaime

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Oct 2008, 04:35 AM
Hi Jaime,

Try  accessing the edit form in the ItemDataBound event as shown below:

CS
 protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
            if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
            { 
                GridEditableItem editedIem = (GridEditableItem)e.Item; 
                RequiredFieldValidator validator=(RequiredFieldValidator)editedIem.FindControl("Validator1"); 
 
            } 
        } 

Thanks,
Shinu

0
Jaime
Top achievements
Rank 1
answered on 21 Oct 2008, 12:21 PM
Hello Shinu,

Thanks for the help. I have to add editItem.ParentItem != null comparison, since I needed to know if the form is in Edit or Insert mode, and I realized that for Insert mode, editItem.ParentItem == null.

Cheers
Jaime
Tags
Grid
Asked by
Jaime
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jaime
Top achievements
Rank 1
Share this question
or