That's your problem. The 3G-data part of the phone isn't working when you're on wifi. It's an either/or not both at once.
Remember how the first iPhone didn't have 3G because Apple said it still used too much power with the chips available at that time? Well, that phone still had wifi. Clearly wifi used much less power than 3G in 2007. I'd guess that it simply held onto that lead even though I'm sure they've both improved since then.
Ah.. well that clears it up. I guess I'll start using WiFi.