First, never open any programs that require data, like safari or mail.

Second, if you don't know if the program will require data, turn on airplane mode before you open it.

Third if you want data, but you want to make sure it only uses your wifi instead of edge/3g....go to settings, enable airplane mode, then go to Wi-Fi and turn it on. Now you will have WiFi but no phone calls or phone-carrier based data transfer.