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

Locating update and cancel buttons on edit form

3 Answers 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eliyahu Goldin
Top achievements
Rank 1
Eliyahu Goldin asked on 29 Oct 2008, 08:20 PM
I have a grid EditMode set to EditForms and EditColumnButtonType = ImageButton.

I want the Update and Cancel buttons change their images on mouse actions. For that I need to set a few clientside event like onmouseover etc. The problem is that I can't locate server side controls for the Update and Cancel buttons on edit form to set their attributes. I handle the ItemCreate or ItemDataBound event and have this code:
            if (e.Item.IsInEditMode && (e.Item is GridEditFormItem))  
            {  
                GridEditFormItem eefItem = e.Item as GridEditFormItem;  
 
                // set right images for buttons  
                ImageButton btnUpdate = efItem.FindControl("btnUpdate") as ImageButton;  
                if (btnUpdate != null)  
                {  
                }  
                ImageButton btnCancel = efItem.FindControl("btnCancel") as ImageButton;  
                if (btnCancel != null)  
                {  
                }  
            }  
 
but it doesn't find any buttons. I tried also setting UniqueName for EditFormSettings.EditColumn and running efItem[uniqueName] to no avail.

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 30 Oct 2008, 05:01 AM
Hello Eliyahu,

To access the Update and Cancel buttons on an AutoGeneratedEditForm you can use the following code.
cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
 
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditableItem item = (GridEditableItem)e.Item; 
            LinkButton updtBtn = (LinkButton)item.FindControl("UpdateButton");           
            LinkButton cnclBtn = (LinkButton)item.FindControl("CancelButton");  
        }  
   } 

Thanks
Princy.
0
Eliyahu Goldin
Top achievements
Rank 1
answered on 30 Oct 2008, 12:23 PM
Thanks, Princy!
0
Daniel
Telerik team
answered on 30 Oct 2008, 12:40 PM
Hello Eliyahu,

You can find the desired information in our documentation:
Customizing the appearance of auto-generated Update/Insert/Cancel buttons

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Eliyahu Goldin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Eliyahu Goldin
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or