How to selected rows on gridview?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fanoftvb
    New Member
    • Mar 2007
    • 29

    How to selected rows on gridview?

    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 CustomersGridVi ew_RowCommand(B yVal sender As Object, ByVal e As GridViewCommand EventArgs)

    ' If multiple buttons are used in a GridView control, use the
    ' CommandName property to determine which button was clicked.

    Dim str As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source= " & Server.MapPath( "database\db1.m db")

    If e.CommandName = "Approve" Then
    'Str = "Update Table3 Set Status='6' Where Status =''"
    'myCommand = New OleDbCommand(St r, con)
    'myCommand.Exec uteNonQuery()
    'Label1.Text = ("Successful ly Approve")
    'con.Close()

    'Dim index As Integer
    Dim mySelectQuery As String = "SELECT State, FileID FROM Table3"
    Dim row As GridViewRow = GridView1.Selec tedRow
    Dim myUpdateQuery As String = "Update Table3 Set State='6' where FileID=" & "'" & row.Cells(1).Te xt & "'" & ""

    Dim myConnection As New OleDbConnection (Str)

    Dim myCommand As New OleDbCommand(my SelectQuery, myConnection)

    Dim myCommand2 As New OleDbCommand(my UpdateQuery, myConnection)

    Dim retvalue As Integer

    myConnection.Op en()

    myCommand2.Exec uteNonQuery()

    Console.WriteLi ne(retvalue)

    Dim myReader As OleDbDataReader

    myReader = myCommand.Execu teReader()

    'Always call Read before accessing data.

    While myReader.Read()
    Label1.Text = ("Successful ly Approve")

    End While

    'always call Close when done reading.

    myReader.Close( )

    'Close the connection when done with it.

    myConnection.Cl ose()
    End If
  • Teenzonez
    New Member
    • Mar 2007
    • 36

    #2
    Hi
    Is it like this that there are approve buttons on every row on the gridview and that if you click on any button on any of the rows only the first row will be updated?
    Please make it clear.

    Regards
    TeenzoneZ

    Comment

    • fanoftvb
      New Member
      • Mar 2007
      • 29

      #3
      Originally posted by Teenzonez
      Hi
      Is it like this that there are approve buttons on every row on the gridview and that if you click on any button on any of the rows only the first row will be updated?
      Please make it clear.

      Regards
      TeenzoneZ
      Yes, there is a approve button on every row and if you click on the first button, the first row will update, click on the second button and the second row will update etc.

      Comment

      Working...