Gridview row deleting not working

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
Im trying to delete a row from my griedview, but it doesnt do anything at all. <asp:GridView ID="appointmentTable" runat="server" Width="316px" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowDeleting="appointmentTable_RowDeleting" DataKeyNames="appID" >
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ButtonType="Image" DeleteImageUrl="~/Images/trash.png" ShowDeleteButton="True" InsertVisible="False" ShowCancelButton="False" >
<ItemStyle HorizontalAlign="Center" />
</asp:CommandField>
</Columns>

</asp:GridView>
Protected Sub appointmentTable_RowDeleting(sender As Object, e As GridViewDeleteEventArgs)
Try
Dim appID As String = appointmentTable.DataKeys(e.RowIndex).Value.ToString
connStr.ConnectionString = "Database=appointment_db; Data Source=localhost; Uid=root; Pwd=; allow user variables=true"
myDa = New MySqlDataAdapter("DELETE * WHERE appID=" & appID.ToString() & "", connStr)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
When im debugging i can see that the value in appID perfectly matches the row im trying to delete, but if i press on delete nothing happens.
What am I doing wrong?

View the full article
 
Back
Top