944,122 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 4943
  • ASP.NET RSS
Apr 1st, 2006
0

datagrid delete function not auto update

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
alfagirl25 is offline Offline
8 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Access deny for backward
Next Thread in ASP.NET Forum Timeline: FAO: Paladine





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC