WiFi connection on my iPad automatically gets disconnected when the screen goes off
This appears to be a common problem.
Try these simple steps provided in the first answer here.
Let me know if they work. If not, please, provide me more details about your iPad settings or/and iOS version.