For future reference I am making a post to solve this issue without factory resetting the device.
You need to use this method if you are in following position(all of them):
1. Data is not enabled on you phone or it is turned off.
2. You have WiFi connection available and you have connected to it before but right now WiFi detection is turned off in your phone.
3. USB debugging* is on in your phone.
4. Have installed Android SDK** on your PC.
5. You have connected your device with your Gmail account.
Connect your phone to your PC. Start Command prompt and use the following command:
adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db update secure set value=1 where name='wifi_on';
Alternatively you can use following command:
adb -s $PHONESERIAL shell "svc wifi enable"
I would go with the first one anyday for the sake of easiness. Restart your phone after this and once you are back On, your WiFi would be enabled and you can log in to your gmail account to unlock your phone.
*USB debugging should always be on. As soon as you get your phone, turn on the USB debugging feature.
**You can get loads of video on youtube demonstrating how to download and install Android SDK on your PC.