There are many causes of fainting, including heart disease, dehydration, epilepsy, medications, low blood glucose level etc.
Many children faint, usually after a painful trigger, like bump in the head or a cut. I have seen adults fainting at the site of blood. These episodes are usually due to vagal nerve stimulation. Vagus is a nerve in the body to calm us down. It gets stimulated by several triggers and the blood flow from the heart slows down. This leads to a reduction in blood supply to the brain. Body is clever and to restore the supply to the brain, we fall down, so that brain gets at the same level as the rest of the body. The blood supply gets back to the brain and we wake up.
Usually no investigations are needed, but sometimes if their is family history of heart disease, we may do an ECG (Electrocardiogram, a trace of the heart) or an EEG (Electroencephalogram, a trace of the brain activity). Their is no treatment required, but I advise children to drink plenty of water, specially in hot weather. If you usually eat a very low salt diet, eat some salty food, as low Sodium in the body can lead to dizziness.
Here are some useful links