下面的代码是删除第一行而不是选中的行。
Protected Sub LinkBtn_Del_Click(sender As Object, e As EventArgs)
Dim intpartID As Integer = gvParticipant.DataKeys(0).Value
Dim comPart As New SqlCommand("usp_Participant_Delete", consql)
comPart.CommandType = CommandType.StoredProcedure
comPart.Parameters.Add("@ParID", SqlDbType.Int).Value = intpartID
consql.Open()
comPart.ExecuteNonQuery()
consql.Close()
selectParticipant()
MultiViewall.SetActiveView(viewDisplayWorkshop)
End Sub
答案 0 :(得分:0)
在调用DataKeys()方法时,您应该获得GridView的选定索引,而不是传递0。在您的情况下,只需使用gvParticipant.SelectedIndex