Ahhh.... Ladies and Gentlemen, we got him! haha!
The code is now working (sort of, more on that in a moment)! I used the line: empID = Convert.ToInt32(dgEmps.DataKeys(chkDel.ItemIndex). ToString())
The line 'dim empID as integer = Convert.ToInt32(chkDel.Item.Cells(2).Text)' is still giving the error 'item is not a member of system.web.ui.webcontrols.datagrid'. Not that it matters, cos the line is working, but do you have ideas why VS doesnt like this line?! I am curious.
I didnt notice that your previous posts where in C# when I looked at them. You would have thought that the different variable declariations, syntax and the fact that the lines ended with ; would have given it away to me!! Even tho I am new to .net, i really should have noticed that

x100
Can I pick your brains for a moment - I am now getting the following errors when I try to delete records and I cant see where they are coming from:
'Value was either too large or too small for an Int32.' I changed the 'toint32' to 'toint16', but this didnt solve the problem, so I altered it again to 'toint64' which seemed to work and it allowed me to delete a record - success! Anyway, when I try to delete more than one record - either by deleting 3 at once or 3 single records in one go, I get this error 'Arithmetic operation resulted in an overflow' I have played around with the code a little, but cant seem to get it to go away. Any ideas?!
Cheers
M
here is the full listing for the sub:
Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.Click
'this function deletes employees from the database
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim chkDel As DataGridItem
For Each chkDel In dgEmps.Items
Dim del_empID As Integer
Dim strSQL As String = ""
chkSelected = chkDel.FindControl("chkdel")
If chkSelected.Checked Then
'get the primary key of the row to delete
del_empID = Convert.ToInt64(dgEmps.DataKeys(chkDel.ItemIndex). ToString())
strSQL = "DELETE EMPLOYEE.* FROM EMPLOYEE WHERE EMPLOYEE.EMP_EMPLOYEE_ID=" & del_empID & ";"
'setting the connection and query details
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "User ID=Admin;" & "Data Source=C:\Inetpub\wwwroot\CompModel\Database\Dev\C ompModel.mdb"
Dim dbConn As New OleDbConnection(strConn)
Dim delCmd As OleDbCommand = New OleDbCommand(strSQL, dbConn)
delCmd.CommandType = CommandType.Text
dbConn.Open()
delCmd.ExecuteNonQuery() 'Execute the UPDATE query
dbConn.Close()
End If
Next
'save the update to the database and show them on the screen
dgEmps.EditItemIndex = -1
DbEditResults()
End Sub