It is a misconception that there is no gravity in space.
An astronaut experiences weightlessness due the fact that as the spacecraft revolves around the Earth, the astronaut is continuously falling towards the Earth. This is similar to what a person standing in an elevator, that is falling freely, would experience. The person would be weightless as the elevator falls.