You have used
<asp:imagebutton id="btnDelete" runat="server" commandname="<b>Delete</b>" xmlns:asp="#unknown"></asp:imagebutton>
which by default runs
DeleteCommand
in
DataSource
. You have provided just
SelectCommand
here.
To run
DeleteRecordByID
,
1. Change the command name
<asp:imagebutton id="btnDelete" runat="server" commandname="<b>MyDelete</b>" xmlns:asp="#unknown"></asp:imagebutton>
2. In RowCommand, check for name and run your code.
If e.CommandName = "Delete" Then
' get the EmpNumber of the clicked row
Dim EmpNumber As Integer = Convert.ToInt32(e.CommandArgument)
' Delete the record
DeleteRecordByID(EmpNumber)
End If