How old is he? When they are young, I feel like they have the attention span of gnats.
Combining that with the fact that there are other dogs nearby and a new place with lots of interesting smells... forget it!
It does get better, though. Use this opportunity to ramp up the training. Train him in different rooms of the house, the garage, the driveway, the sidewalk, you name it. Your training, if you remain persistent, will pay off!
I will tell you a funny story if it will make you feel better. On the first day of intermediate obedience training, I sat with my dog at my feet. I had packed a small tupperware container of treats. Well, the instructor was talking so I was paying attention to the instructor... and NOT paying attention to the sassy puppy at my feet (who I expected would be on his BEST behavior because, after all, this is intermediate obedience! This wasn't our first rodeo!)
Well, next thing I know, there was a loud 'pop' noise and then an EXPLOSION of treats. My dog managed to pop open the tupperware container of treats and they burst everywhere. The entire class was slack-jawed. I was stunned. I couldn't even react at first, and by the time I did, my dog had scarfed up every single treat. We had to borrow treats from others for the rest of class that day
Anyway, I had two ways of viewing it. I could be so embarrassed that my dog exploded a container of treats during intermediate OB class that I would never come back... or I could think, well, it can only go up from here! I went with the latter!