"The Messenger of Allah said, 'No one of you should stand to pray when he feels some discomfort (because of needing to urinate or defecate).'"
Sunan Ibn Majah Book 1, Hadith 352