I have a simple windows form application in vb.net ,now I am trying to use the code in asp.net web form .I want to delete the selected row from gridview and database table .I am encountering the following error:
current row / remove is not a member of System.Web.UI.web control
I have just gotten into asp.net and have tried few ways to do this but dont understand well enough.
if someone could show me some code that i could add to my form i would appreciate it
Thanks
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button3.Click
Dim mResult
Dim ObjConnection As New OleDbConnection()
mResult = MsgBox("You are really want to delete the slected record?", _
vbYesNo + vbQuestion, "Removal Confirmation")
If mResult = vbNo Then
Exit Sub
End If
ObjConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\testdb2.accdb"
ObjConnection.Open()
Try
Dim ObjCommand As New OleDbCommand()
ObjCommand.Connection = ObjConnection
ObjCommand.CommandText = "delete from table1 where date_='" & Me.GridView1.CurrentRow.Cells(0).Value & "'"
ObjCommand.ExecuteNonQuery()
Finally
ObjConnection.Close()
End Try
Me.GridView1.Rows.Remove(Me.GridView1.CurrentRow)
End Sub
current row / remove is not a member of System.Web.UI.web control
I have just gotten into asp.net and have tried few ways to do this but dont understand well enough.
if someone could show me some code that i could add to my form i would appreciate it
Thanks
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button3.Click
Dim mResult
Dim ObjConnection As New OleDbConnection()
mResult = MsgBox("You are really want to delete the slected record?", _
vbYesNo + vbQuestion, "Removal Confirmation")
If mResult = vbNo Then
Exit Sub
End If
ObjConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\testdb2.accdb"
ObjConnection.Open()
Try
Dim ObjCommand As New OleDbCommand()
ObjCommand.Connection = ObjConnection
ObjCommand.CommandText = "delete from table1 where date_='" & Me.GridView1.CurrentRow.Cells(0).Value & "'"
ObjCommand.ExecuteNonQuery()
Finally
ObjConnection.Close()
End Try
Me.GridView1.Rows.Remove(Me.GridView1.CurrentRow)
End Sub