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

Adding Confirmation to "Update" ,"Insert","Cancel" Buttons

1 Answer 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mohammad
Top achievements
Rank 1
Mohammad asked on 18 Sep 2012, 02:18 PM
Hi , 

I  looking the code to add the Confirmation to "Update" ,"Insert","Cancel" Buttons same like the "delete" Button as given below

  protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if ((e.Item is GridDataItem))
            {
                LinkButton button = e.Item.FindControl("AutoGeneratedDeleteButton") as LinkButton;
                button.Attributes["onclick"] = "return confirm('Are you sure you want to delete " +
                "" + "?')";
            }
        }
Expecting your valuable advise

Regards

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Sep 2012, 06:25 PM
Hello,

Please try with below code snippet.

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item.IsInEditMode)
            {
                if (e.Item is GridDataInsertItem)
                {
                    GridEditableItem editItem = (GridEditableItem)e.Item;
                    LinkButton InsertButton = (LinkButton)editItem.FindControl("PerformInsertButton");
                    // add onclick attribute here
                    LinkButton CancelButton = (LinkButton)editItem.FindControl("CancelButton");
                    // add onclick attribute here
                }
                else
                {
                    GridEditableItem editItem = (GridEditableItem)e.Item;
                    LinkButton updateButton = (LinkButton)editItem.FindControl("UpdateButton");
                    // add onclick attribute here
                    LinkButton CancelUpdateButton = (LinkButton)editItem.FindControl("CancelButton");
                    // add onclick attribute here
                }
            }
 
 
}


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Mohammad
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or