Protected Sub btnMultipleRowDelete_Click2(ByVal sender As Object, ByVal e As EventArgs)
For Each row As GridViewRow In GridView1.Rows
Dim MatId As String = Convert.ToString(GridView1.DataKeys(row.RowIndex).Value)
Dim checkbox As CheckBox = CType(row.FindControl("CheckBox1"), CheckBox)
If checkbox.Checked Then
Dim a As String
a = GridView1.DataKeys(row.RowIndex).Values("MatStatus").ToString()
SqlMaterial.UpdateCommand = "Update Material SET [MatStatus] = 'Inactive' Where MatId ='" + MatId + "'"
SqlMaterial.Update()
Dim sb As New StringBuilder
sb.Append("<script type='text/javascript' language='javascript'>")
sb.Append("alert('ลบข้อมูลเรียบร้อยแล้ว');")
'sb.Append("document.location ='manageMatTypeData.aspx';")
sb.Append("</script>")
Page.ClientScript.RegisterStartupScript(Page.GetType, "RedirectScript", sb.ToString)
Else
Page.ClientScript.RegisterStartupScript(Page.GetType, "testAlert", "<script language='javascript'>alert('กรุณาเลือกข้อมูลที่ต้องการลบ');</script>")
End If
Next row
End Sub