Hi, I'm having problem with my rows on gridview. When i click on the approve button, only the first row of the grid will update. Does anyone know how to make it that when i click on the different button on different row different rows will update. My code is as below...
Sub CustomersGridView_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
' If multiple buttons are used in a GridView control, use the
' CommandName property to determine which button was clicked.
Dim str As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("database\db1.mdb")
If e.CommandName = "Approve" Then
'Str = "Update Table3 Set Status='6' Where Status =''"
'myCommand = New OleDbCommand(Str, con)
'myCommand.ExecuteNonQuery()
'Label1.Text = ("Successfully Approve")
'con.Close()
'Dim index As Integer
Dim mySelectQuery As String = "SELECT State, FileID FROM Table3"
Dim row As GridViewRow = GridView1.SelectedRow
Dim myUpdateQuery As String = "Update Table3 Set State='6' where FileID=" & "'" & row.Cells(1).Text & "'" & ""
Dim myConnection As New OleDbConnection(Str)
Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
Dim myCommand2 As New OleDbCommand(myUpdateQuery, myConnection)
Dim retvalue As Integer
myConnection.Open()
myCommand2.ExecuteNonQuery()
Console.WriteLine(retvalue)
Dim myReader As OleDbDataReader
myReader = myCommand.ExecuteReader()
'Always call Read before accessing data.
While myReader.Read()
Label1.Text = ("Successfully Approve")
End While
'always call Close when done reading.
myReader.Close()
'Close the connection when done with it.
myConnection.Close()
End If