sgray128 12/9/2013 7:42:22 PM

ASP.NET - RadGrid - Confirm Delete

This code sample shows how to get a 'Confirm Delete?' popup on an ASP.NET radgrid                       


<telerik:RadGrid ID="RadGrid5" runat="server">
  <MasterTableView AutoGenerateColumns="False">
      <telerik:GridBoundColumn HeaderText="ContactName" DataField="ContactName" UniqueName="ContactName">
      <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">


Private Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
    If TypeOf e.Item Is GridDataItem Then
        Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
        Dim contactName As String = dataItem("ContactName").Text
        Dim button As LinkButton = CType(dataItem("DeleteColumn").Controls(0), LinkButton)
        button.Attributes("onclick") = "return confirm('Are you sure you want to delete " & contactName & "?')"
    End If
End Sub