Do not let this stuff get airborn. The reason DE is effective for gnats is that it cuts their undersides as they try to fly into the soil. A foliar spray will do the same thing to your lungs. I have been fighting gnats for most of a grow, and the only tried and true remedy that I've avoided is DE, because it's just so nasty. If I had to, I would use it, but I consider it a last resort - I'd rather go for perlite, which I hate because of the floatation before risking my health with most DE preparations (I can really only find one type, the kind in the big yellow bag). Supposedly food-grade DE is safer, but I've never been able to locate it. Keep pets, kids, slow friends, etc. away from it, it's a severe irritant.
The way to correct the problem, if you decide to use DE, is to put a layer of it on top of the soil. Make sure you get a mask and some eye protection, and probably gloves. It's nasty shit, and you don't want it getting on you. It will prevent adults from flying into the soil to lay eggs (well, it won't prevent them from flying there, but it will prevent them from living if they do), and prevent larvae from escaping once they become adults. However, the larvae can do quite a bit of damage to the roots before they emerge.
Your best bet to get rid of all the adults quickly would probably be a
pyrethrin bomb, but this is not great for the plants, and I'd use it as a last resort (this was my second to last resort before DE, lol, I used a
pyrethrin spray once before I found out that it kills beneficials, and I have a bomb on standby, but I won't use it unless something far more threatening than gnats shows up - in other words, like an airbag, I hope I never have to use it). For the larvae and eggs, I have used a bunch of different things, and what has worked best for me is
Azamax as a soil drench. I have only seen a hand full of gnats in the past couple weeks, since I went and got more
azamax. I have also started using crushed mosquito dunks on the top layer of my soil, which seems to help a lot.
Good luck! Oh, one more thing helps a lot, get faster draining soil or water less often!