| | |
datagrid delete function not auto update
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2006
Posts: 8
Reputation:
Solved Threads: 0
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
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
- Auto Update and manual update fails on XP SP2 Home Edition (Windows NT / 2000 / XP)
- Add/Remove Progs, Auto Update, MS Update inop (Windows NT / 2000 / XP)
- File scan and auto update (VB.NET)
- Creating an auto update function in an app (C)
- Popup-MediaTicketsInstaller-cash8.exe-HiJackThis Log posted (Viruses, Spyware and other Nasties)
- How can I delete Hosts: 1159680172 auto.search.msn.com? (Viruses, Spyware and other Nasties)
- offeroptimizer everywhere!!!!!! (Viruses, Spyware and other Nasties)
- Auto update columns? (Database Design)
Other Threads in the ASP.NET Forum
- Previous Thread: Access deny for backward
- Next Thread: FAO: Paladine
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers





