alfagirl25 0 Newbie Poster

hi guys..i have a problem here..i have added delete function in datagrid, along wif confirmation box.
but after i click the delete button, it did not auto delete, i have to build n browse(in visual studio.net) then only the deleted item disappear.

pls help:

the code:
Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand
Dim iID As Integer = Convert.ToInt32(e.Item.Cells(2).Text) 'Grab the ID from the hidden column
'Dim myConnection As New SqlConnection(Your Northwind ConnectionString Here)


Dim myDeleteCommand As SqlCommand = New SqlCommand("DELETE FROM tblDegree3 WHERE EntryID = '" & iID & "'", SqlConnection1)
myDeleteCommand.CommandType = CommandType.Text

SqlConnection1.Open() 'Open the connection

myDeleteCommand.ExecuteNonQuery() 'Delete the record
SqlConnection1.Close() 'Close the connection
DataGrid1.DataBind()

End Sub

Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
If e.Item.ItemType <> ListItemType.Header And _
e.Item.ItemType <> ListItemType.Footer Then
'Now, reference the LinkButton control that the Delete ButtonColumn
'has been rendered to
Dim deleteButton As LinkButton = e.Item.Cells(1).Controls(0)

'We can now add the onclick event handler
deleteButton.Attributes("onclick") = "javascript:return " & _
"confirm('Are you sure you want to delete Entry #" & _
DataBinder.Eval(e.Item.DataItem, "EntryID") & "?')"
End If
End Sub