title: Update checked Gridview rows
body: <p>I had a problem with updating only the checked rows in <code>GridView</code> because I need to update one column cell value based on the ID value of the checked rows only.</p>
  
  <p>I tried this code but it updates random rows, not the checked:</p>
  
  <pre><code>        Try
              Dim I As Integer
              For I = 0 To GridView1.SelectedRowsCount() - 1
                  If (GridView1.GetSelectedRows()(I) &gt;= 0) Then
                      Dim strID As String = GridView1.GetRowCellValue(I, "ID")
                      Dim strUpdate As String = "UPDATE records SET payment_order= @payment_order where ID = @ID"
                      cmd.CommandType = CommandType.Text
                      cmd.CommandText = strUpdate.ToString()
                      cmd.Parameters.Clear()
  
                      cmd.Parameters.AddWithValue("@payment_order", rfnd_id_lbl.Text)
                      cmd.Parameters.AddWithValue("@ID", strID)
                      cmd.Connection = con
                      con.Open()
                      cmd.ExecuteNonQuery()
                  End If
              Next
  
  
          Catch ex As SqlException
              Dim errorMsg As String = "Error in Update"
              errorMsg += ex.Message
              Throw New Exception(errorMsg)
          Finally
              con.Close()
          End Try
  </code></pre>
  
  <p>Can anyone help me solving this issue please?</p>