I just started MVC and I'm having troubles on saving and IList model to database. I have a for loop, looping through a list as suggested by all the posts i've read on how to save multiple items inside the model. However, I cannot see examples or articles on how i can render a partial view just by passing a parameter
This was the original code. Which returns null model on submit.
@foreach (var item in Model)
{
Html.RenderPartial("_Budget", item);
}
And this is the current code which I found from the suggestions. But I can't figure out how i can render the partial view every loop. Any advise would be appreciated. Thanks.
@for (var i = 0; i < Model.Count; i++)
{
Html.RenderPartial("_Budget", item);
}
Try to use @Html.Partial
@foreach (var item in Model)
{
@Html.Partial("_Budget", item);
}