A dishwasher will clean a toilet brush however it can be unsanitary to put your toilet brush in the dishwasher and I would not recommend doing it.
If you do put your toilet brush in the dishwasher you should run some bleach in the dishwasher with the toilet brush to kill bacteria off of the brush and dishwasher.
Then run the dishwasher through another cleaning cycle with some bleach again to clean the dishwasher out and prevent contamination of your dishes.
I tried putting a toilet brush in my moms dishwasher as a kid and she wouldn't let me do it as she said it was gross and to just wash the toilet brush off in the bathtub instead.