I'm working with a very stubborn horse while riding, he's a sweet heart on the ground but when i get on he has to get his way. Do you have any ideas on how to build each others trust?

Try liberty work.I gained trust with my horse and he is listening way better
Make him do what you want! Remember you are in control
Gain one another's respect with a lot of groundwork (lunging, backing, yielding hindquarters, etc) to ensure he respects you.

If he still seems to be stubborn after a lot of groundwork, I suggest you get his tack checked to ensure he isn't in any pain or discomfort which could be resulting in his behaviour.
If his tack is fine and you've worked him on the ground for a week or two and he still shows unwanted behaviours while riding and always seems to 'get his way', then let him get his way.
But don't make it easy.
You allow the horse to make the mistake of putting himself into more work than he needs to instead of saying 'no'. If you tell him no and try and get your own way, the horse will most likely win, and that's fine. But make it difficult to 'win' and he will want to listen to what you are asking rather than making his own way be harder work.
"Make the wrong thing hard and the right thing easy"
As soon as he puts a step wrong, work him a lot and return to what you were previously doing. If he puts another step wrong, work him again.
This is the most reliable method I've used. Punishment never works, but making the horse work harder than he needs to does.
Good luck!
Don't let him get his way? My horse used to be a bully undersaddle until I insisted on doing things my way. Two weeks later he's a different horse.
Round pend your horse with out any lunge line
You could use treats while training. Your horse will appreciate that!
Join up and liberty
Join the fun and sign up to connect with our 200,000 members!