datagrid delete function not auto update

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2006
Posts: 8
Reputation: alfagirl25 is an unknown quantity at this point 
Solved Threads: 0
alfagirl25 alfagirl25 is offline Offline
Newbie Poster

datagrid delete function not auto update

 
0
  #1
Apr 1st, 2006
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC