You can't use a foreach loop for that, you have to use a for loop.
for (int i=0; i<Model.MyClass.param3.Count; i++)
{
@Html.HiddenFor( model => model.MyClass.param3[i])
}
The reason for this is the HiddenFor
helper needs some way of assigning unique names to each field for the model binding to work. The i
variable accomplishes this.
In your case you;ll need to do some refactoring to implement this. I don't think ICollection
or HashSet
supports indexing, so you'll need to cast it to a List
or some collection that does support indexing.
See this excellent blog post on the subject.