Ron uses the Wingardium Leviosa charm to levitate the troll's club and knock it out, saving Hermione. This is the levitation spell taught in Charms class that Ron struggles with initially. Hermione is trapped in the bathroom with the troll during Halloween.