First I tried everything to get the bad smell out of the dishwasher. Bleach, vinegar, Tang, baking soda, Dishwasher Magic Dishwasher Disinfectant. I even took most of it apart to clean it inside. They all helped. Dishwasher Magic seemed to last the longest and I got into the habit of using it regularly.
Then when I was swapping out the old dishwasher with a new one I found the source of that foul swampy odor. It was the drain hose!
The ridges in the drain hose collected a lot of gunk that would start to smell in between the long periods where it wasn't being used.The only real fix would have been to replace the drain hose, which I wound up doing when installing the new dishwasher.
One of the reasons I think the hose started to smell is because the drain hose wasn't installed correctly to begin with. The dishwasher drain hose needs to be installed with an air gap or at the very least needs to have a high loop that attaches to the bottom of the counter.
The contractor that installed this dishwasher didn't use an air gap or put a loop in.
The reason they didn't put a loop in is because the hose was too short. The dishwasher had one small cabinet in between it and the sink cabinet and the hose wasn't long enough to reach the drain and make a loop.
If your dishwasher smells you can easily check the drain hose. Just unscrew the hose clamp from where it connects to your sink's tail pipe or to your garbage disposal and sniff it. If it smells terrible it's time for the drain hose to go.
To replace the drain hose you'll need to disconnect the water and power from your dishwasher, slide it out, install the new drain hose and hook everything back up.
If your drain hose isn't long enough to make a high loo[ you can get this Drain Waste Hose Extension Kit or hook it up through an air gap that is installed at the level of your counter.