WebGrid Delete Selected Row

Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
DeveloperMember
Hello Intersoft,


I want a user to be able to select a row on my webgrid and then click on a Delete Button to delete the selected row from the database and from the webgrid. (im not that good in asp.net)



If there is no row selected a DialogBox appears with "please selecta a row"

if there is a row selected a DialogBox appears with two buttons to confirm or cancel.

But if you confirm the delete, nothing happens. Where is my mistake?





<script runat="server"> Sub DeleteBtn_Click() Handles DeleteBtn.Click 'Delete Button If WebGridEmpf.SelectedRowKeyValue <= "0" Then ErrorMSG.Visible = True 'Dialog box appears with "Please select a row" Else DeleteMSG.Visible = True 'Dialog box appears with: "Do you want to delete this row? yes/no" End If End Sub Sub BtnYes_click() Handles btnYes.Click Dim myConnection As OleDbConnection Dim myCommand As OleDbCommand Dim strSQL As String Dim id As Integer id = WebGridEmpf.SelectedRowKeyValue strSQL = "DELETE * FROM MyTable " _ & "WHERE ID='" & Replace(id, "'", "''") & "';" myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " _ & "Data Source=C:\inetpub\wwwroot\MyWebsite\DB\Mydatabase.mdb") myConnection.Open() myCommand = New OleDbCommand(strSQL, myConnection) myConnection.Close() DeleteMSG.Visible = False 'Dialogbox disappears End Sub Sub Btnno_click() Handles btnNo.Click Response.Write("sie haben nein gelkickt") DeleteMSG.Visible = False 'Dialogbox disappears End Sub </script>





All times are GMT -5. The time now is 2:55 PM.
Previous Next