Here is a portion of a partial:
@model IEnumerable<BLL.DomainModel.Jerk>
@foreach (var jerk in Model)
{
using (Html.BeginForm("AddJerk", "Jerk", FormMethod.Post, new { @class = "jerkListForm" }))
{
@Html.HiddenFor(jerk => )
@jerk.Name
...
}
}
The type that the HiddenFor
lambda is looking for is the same as the @model
(IEnumerable), whereas I'm looking for a single object within that IEnumerable.
What am I missing? Why is it still looking for a collection inside of the foreach loop?
@model IEnumerable<Type>
@foreach(var item in Model)
{
@Html.HiddenFor(model => item)
}
Don't forget that Type must be de/serializable in order for this to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With