^ Mosquito Dunks\Bti (a certain kind of bacillus bacterium) is quite effective at controlling fungus gnat populations. Unlike most other suggestions the Bti actually kills the larval stages of the gnat. This is important due to the life cycle of a fungus gnat, which takes roughly a month. If the measures you take are only to kill the adults you're less likely to be successful. The toxins produced by Bti are very selective and wont harm anything else in the soil.
Here's what I would recommend: get the dunks, which are available at every home improvement center. You can break a single dunk in half or in quarters. Wear a dust mask (latex gloves are good, too). Take a good chunk and break it up with your hands, a hammer, or use a coffee grinder (one you don't use to grind coffee with). Soak the broken dunk chunk in a gallon of water, shaking periodically over the course of a day. Use this water to irrigate your plants with.
Have a vacuum standing by while irrigating the plants. Use the vacuum to the take care of the adults that fly away from the soil to avoid being drowned. Yellow traps are a good idea, too, of course. Repeat the vacuuming daily or at least each time you water, and repeat the Bti application every two weeks. This way you're killing adults as well as larvae and it is much more likely to result in the gnats being wiped out.