Q:

Why did the first Boeing B17 test flight crash on takeoff?

Wikipedia says that the control surfaces were locked. 
What does this mean, and if the control surfaces cannot be moved, how did the aircraft get into the air in the first place?

A:

The prototype aircraft had small "blocks" (more like wedges) which were used to prevent the control surfaces moving in the wind and potentially damaging the control surfaces, or even moving the aircraft on the ground. A bit like putting chocks under the wheels to stop the aircraft rolling.
These were not removed when the aircraft was taken on a test flight, so the control surfaces could not move. Essentially, they were "fixed" in an approximately neutral position. Imagine if you couldn't move your steering wheel in your car because someone had put wedges next to your front wheels to prevent them turning: that's basically the situation the pilots were dealing with, but unlike you they can't just hit the brakes and stop once the aircraft is in the air.
The Boeing 299 / B-17 are "taildragger" aircraft.
As you can see in this photograph which I won't link directly due to the size, the aircraft's nose is pointing quite sharply "up" when on the ground.
Here's a B-17, which isn't identical to the Type 299 but is close enough that it makes no difference. Hopefully this gives you the visual to see why the aircraft will lift off at a high enough speed.

When accelerating the nose being pointed slightly up gives a positive angle of attack for the wings. This means that once the aircraft gets above stall speed, it will naturally lift off into the air. Essentially, the aircraft is already pitched slightly up before any control surfaces are moved.
That also means that when the aircraft takes off, it will climb - at least initially. With the locked elevators, there is no way to change the pitch angle of the aircraft, and the aircraft will either pitch up or down naturally - there is almost no chance that the aircraft would be perfectly trimmed by accident.
In this case, the position the elevators were locked caused the aircraft to continue pitching up until it stalled. The crew had no way to correct this and the aircraft stalled out, rolled and crashed into the ground.

A:

If you follow through the links to the one on Ployer Peter Hill the B-17 (Model 299) test pilot, it says this about his death:

On October 30, 1935, Ployer Peter Hill died as a result of injuries received from the crash of the Boeing experimental aircraft Model 299 at Wright Field. The crash occurred because the crew neglected to remove the devices intended to keep the control surfaces from moving when the plane was on the ground. This aircraft was the prototype of what would later become the famous B-17 Flying Fortress of World War II. Major Hill was buried in Newburyport, Massachusetts, on November 3, 1935.

So basically they forgot to remove the gust-lock devices. Yet another case for doing a thorough pre-flight check and control check before taking off.
I can't find any evidence or anything to suggest the aircraft ever left the ground, however its possible for the aircraft to become airborne just through the amount of lift generated at higher speeds. Many airplanes will fly even with slight nose-down attitudes. Its also possible that the gust locks still allowed enough elevator movement to get off the ground. The link that Federico provided seems to suggest that the elevator was in the up position and allowed the aircraft to climb into a stall, but still not completely clear since most tail-draggers require some down-elevator to get the tail up, then up elevator to climb.

