(from what my mother tells me -it worked on us)
Whatever you do DO NOT reinforce the negative behavior. If he is whining, don't give him something nice to make him stop whining. That shows him that if he whines, he'll get something good out of it for him.
Essentially, you build up good behavior and punish bad. Sounds simpler than it is, i know. What seems to work best amongst my mom's group of friends (all mothers) is to put the child in an isolated place BY HIM SELF. Do not sit and baby him through his time out. Let him sit and whine and show him that his whining is not affecting you and that he's only punishing himself by continueing. When he has "served his time" (of whatever you see fit...3min...5min..your call). He can come out. If he is behaving himself well after his punishment, reward his good behavior.
Obviously, you can't reason with a 2 year old and they don't understand WHY the whining is bad. You have to break it down to as simple as possible so that he will understand. Good behavior= treats, toys, your praises, etc.. Bad behavior = time out, NO toys, NO treats, none of your praise... I think you get the general idea.
Just be strong and be the parent. If your child sees that he can bend you to his will, rest assured he absolutely will do just that.