Chapter 340
Prohibition of raising one's Eyes towards the sky during As-Salat (The Prayer)

1754. Anas bin Malik (May Allah be pleased with him) said: The Messenger of Allah (PBUH) said, "How is it that some people raise their eyes towards the sky during As-Salat (the prayer)?'' He stressed (this point) and added, "People must refrain from raising their eyes towards heaven in Salat (prayer), or else their sights will certainly be snatched away.''
[Al-Bukhari].

Commentary: Looking towards the sky during prayer disturbs the concentration in Salat and there is a stern warning against this bad habit. One can, however, do so after Salat, i.e., during one's supplications.