Protected Sub lbntDelCType_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbntDelCType.Click
Me.lbntDelCType.Attributes.Add("Onclick", "return confirm('คุณต้องการที่จะลบข้อมูล');")
If conn.State = ConnectionState.Open Then
conn.Close()
End If
conn.Open()
Dim i As Integer
For i = 0 To dgvCType.Rows.Count - 1
Dim ckbCTypeDelRow As CheckBox = dgvCType.Rows(i).FindControl("chkGCTypeDel")
If ckbCTypeDelRow.Checked = True Then
strSQL = "DELETE FROM Contract_Type WHERE CType_ID = '" & dgvCType.DataKeys(i).Value & "'"
cmd = New SqlCommand(strSQL, conn)
cmd.ExecuteNonQuery()
End If
Next
ShowDataCType()
End Sub