It should be held on with something like this:
http://www.thefastenerwarehouse.com/...75/6936841.htm
Being able to fix it completely depends on whether you can safely get under the car or not, and how bad (if any) damaged the under tray is.
But if it's hanging, you may have torn the holes, damaging the under tray. In that case, you may need a new one. You may be able to drill new holes in it, and mount the fasteners in a different hole on the body. You could even rig it up by drilling little holes and using zip ties. Obviously that wouldn't be the best cosmetic option.
Also with those kind of fasteners, they can be a little tricky to remove. When you're loosening the screw part, use the least amount of pressure possible. Doing that will make it loosen easily. If you put too much pressure, it will just spin and spin.