I'm trying to figure out why this existing delete code isn't being called.
1 Private Sub dgPhones_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgPhones.ItemCommand
2 Dim allowDelete As Integer = 100
4 Select Case e.CommandName
6 Case "Edit"
10 pnlEditPhone.Visible = True
11 btnAddPhone.Visible = False
13 pnlPhones.Height = New System.Web.UI.WebControls.Unit(180)
14 Case "Delete"
15 allowDelete = DeletePhone(CInt(dgPhones.DataKeys(e.Item.ItemIndex)))
16 If allowDelete = 100 Then
20 Response.Write("alert('You must make another phone number the Primary phone before you delete.')")
22 End If
23 End Select
25 End Sub
The problem is, previously this was working fine but the change I made was to use an actual ImageButton in an ItemTemplate rather than a stupid ButtonColumn or whatever that they had in this DatGrid Previously because first of it's easier to work with and second, I needed to fire off an OnClick event as well.
Anyway, here's my new ImageButton for the delete button defined in my DataGrid:
1 <asp:TemplateColumn HeaderText="Primary">
2 <ItemStyle Wrap="False" HorizontalAlign="Left" CssClass="datagridcell" />
5 <asp:ImageButton ID="btnDelete" ImageUrl="/Images/icons/redx.gif" CommandName="Delete" runat="server" />
Any help or ideas would be greatly appreciated.