โค้ดส่วนที่ error แล้วก้ออยากทราบว่าส่วนเงื่อนไข If ที่ขึ้น error ต้องใช้คำสั่งอะไรคะ T T
โค้ดผิดตรงที่ขีดเส้นใต้อ่าคะ
Code (VB.NET)
Protected Sub deletedata()
Dim sql As String
Try
For Each row As GridViewRow In GridView1.Rows
If CType(row.FindControl("chkDelete"), CheckBox).Checked = True Then
sql = "DELETE FROM tb_mate_ann WHERE mate_id ='" & GridView1.DataKeys(row.RowIndex).Value & "'"
ObjDb.ExecuteNonQuery(sql)
btnDelete.Attributes.Add("OnClick", "return confirm('Confirm to delete record')")
End If
Next
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Protected Sub deletedata()
Dim sql As String
Dim chk As CheckBox
chk = CType(Rows.FidnControl("ChkDelete"), CheckBox)
Try
For Each row As GridViewRow In GridView1.Rows
If chk.Checked = True Then
sql = "DELETE FROM tb_mate_ann WHERE mate_id ='" & GridView1.DataKeys(row.RowIndex).Value & "'"
ObjDb.ExecuteNonQuery(sql)
'btnDelete.Attributes.Add("OnClick", "return confirm('Confirm to delete record')")
End If
Next
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub