Current location: Hot Scripts Forums » Programming Languages » ASP » delete selected row in gridview


delete selected row in gridview

Reply
  #1 (permalink)  
Old 10-16-11, 11:26 PM
david079 david079 is offline
New Member
 
Join Date: Sep 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
delete selected row in gridview

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:
Undefined function 'GridView1.Rows' in expression.
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

Code:

 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_=GridView1.SelectedRow "

            ObjCommand.CommandText = "delete from table1 where date_=GridView1.Rows(GridView1.SelectedIndex) "
            ObjCommand.ExecuteNonQuery()
        Finally
            ObjConnection.Close()
        End Try

      
    End Sub
Reply With Quote
Reply

Bookmarks

Tags
asp.net


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table(grid) with possible delete row option ELV1I2 PHP 6 06-21-07 07:38 AM
Delete a mysql row after a number of days Oskare100 PHP 5 11-18-06 06:28 AM
Delete files/directories selected in MySQL ronlar PHP 3 08-08-05 08:41 AM
change colour of selected row in listview vbsoftwareengineer Visual Basic 0 02-19-05 09:35 AM
Delete row from mysql error. bigkid PHP 1 08-05-04 09:36 PM


All times are GMT -5. The time now is 04:12 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.