How to make it work without hard coding.
@foreach (var item in Model.Items)
{
//not working - it's assigning blank value
@Html.HiddenFor(o => o.ItemIds, new { @value = item.Value.ToString() })
//working
@Html.Hidden("ItemIds", item.Value);
}
You could change your
Model.Itemsdeclaration from anIEnumerableto anList, then reference your item via the index like so: