The datakey is a property of the datagrid that gets or sets the property. To the the key field for the selected row, you have to know where in the grid it exists and get it like this:
'My example assumes the key value is a string
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles DataGrid1.ItemCommand
If e.CommandName = "Select" Then
Dim strKey As String
strKey = e.Item.Cells(cell # here).Text
Response.Write(strKey)
End If
End Sub
|