There are a variety of solutions that can be undertaken to eliminate foul odors from a dishwasher such as cleaning the door gasket and drain filter, removing food from other areas of the appliance, and using products to neutralize the odors. Regular maintenance ensures odors don't return.
If a dishwasher is constantly producing a foul odor, it is likely that the door gasket and drain filter are in need of a good clean. The door gasket is the black rubber tubing around the edge of the dishwasher's door that prevents water from escaping when the appliance is in use. Bits of food and mold can easily become trapped in the rubber, and cleaning the area with a soapy cloth can eliminate and prevent bad odors. The drain filter at the bottom of a dishwasher also collects pieces of food and bacteria, which can create a bad smell. Removing the filter and scrubbing it clean helps get rid of any bad smells.
It is also worth checking other areas of the dishwasher that are easily accessible for food particles and other bits of mold that are trapped. Another tip for eliminating bad odors is to use some vinegar in a wash cycle by itself. Vinegar is a great product for neutralizing bad odors.