You seem to have the fieldset
inside foreach
and you're closing it outside.
I've seen similar problems with razor. e.g. check this post
The foreach block is missing a closing "}" character
And it doesn't make sense to me - you should move the first/opening outside the loop I think.