How does Hypnosis work?

I just saw a wonderful explination of this on the Discovery Channel show Human Body Pushing the Limits – Sensations Episode. It showed an incredible example of a dentist using hypnosis on a man getting a filling. He gets his tooth drilled and filled and feels no pain. It explained how hypnosis can do this! It was really cool to see.