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

Confirm button extender with RadGrid Automatic Operations

2 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sam
Top achievements
Rank 1
sam asked on 18 Jul 2010, 11:01 PM
Hello i am using Rad Grid with automatic operations
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
        AllowSorting="True" DataSourceID="SqlDataSource1" GridLines="None" AutoGenerateDeleteColumn="True"
        AutoGenerateEditColumn="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
        Skin="Inox" AllowAutomaticDeletes="True" AllowMultiRowEdit="True"
        EnableHeaderContextMenu="True"  TableLayout="Fixed">


how can i add confirm button extender  RadGrid when user click on column delete  inside the RadGrid?
i want to display "Are you sure you want to delete this row or record? "

thanks for any help

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 19 Jul 2010, 06:54 AM
Hello Sam,

In order to achieve this,access the  AutoGeneratedDeleteButton from code behind and attach one 'onclick' event for confirmation.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem)
       {
           GridDataItem item = (GridDataItem)e.Item;
           LinkButton deleteBtn = (LinkButton)item.FindControl("AutoGeneratedDeleteButton");
           deleteBtn.Attributes.Add("onclick","return confirm('Are you sure you want to delete this row or record?')");
       }
   }

Or you can use GridButtonColumn with CommandName as 'Delete' and ConfirmText  which is shown below.

ASPX:
<telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this row or record?"
                    CommandName="Delete" Text="Delete">
</telerik:GridButtonColumn>

Thanks,
Princy.
0
sam
Top achievements
Rank 1
answered on 19 Jul 2010, 08:36 PM
Thank you very much Philip you are always saving my life
it works

and this is the code for VB
Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemCreated
        If TypeOf e.Item Is GridDataItem Then
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
            Dim deleteBtn As LinkButton = DirectCast(item.FindControl("AutoGeneratedDeleteButton"), LinkButton)
            deleteBtn.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this row or record?')")
        End If
    End Sub
Tags
Grid
Asked by
sam
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
sam
Top achievements
Rank 1
Share this question
or