I'm fairly new to MVC and I wondered if something along the following lines is possible?
I'm trying to create html helpers for textboxes for new items in a list. The amount of items in the list is dynamic and unknown.
Model (person.cs)
public class Person
{
public List<string> Strings = new List<string>();
}
View (Index.cshtml)
@model Project.Models.Person
@{
int length = (int)Session["Length"];
for (int i = 0; i < length; i++)
{
Html.TextBoxFor(p => p.Strings[i])
}
}
Obviously this code does not work, but it is the simplest representation of what I want to achieve, and I was wondering what I can do to make this code work, or any workarounds to allow me to dynamically add or create new items in a collection.