Check the overfill float switch
The overfill float has to be able to move up and down freely for the dishwasher to be able to fill properly. If an object of any kind is blocking it, remove the object. Make sure the overfill float isn't stuck at the highest point, because in that position, the fill valve won't let any water in to fill the tub.
Replace the water inlet valve
If the water inlet valve gets stuck in a closed position, the dishwasher won't fill with water; if it's stuck in the open position, the dishwasher fills with water even if it isn't turned on. Replace the water inlet valve if it doesn't operate properly.