I've got the next question about the right way of adding items to a list in MVC.
Let's say I got the following model:
public class Student
{
public String Name { get; set; }
public List<Lesson> Lessons { get; set; }
}
Now I'm in the Student Create view in which the user can add multiple Lessons. The way the view looks is that there is a dropdown in which you can select a lesson and a button to add a new dropdown. This way a person can add multiple lessons to the Lessons variable.
Now I tried alot of different approaches but never seemed to have the right one because I don't like having this in the view:
@Html.DropDownListFor(model => model.Lessons[0].Id, new SelectList(...), "Select lesson")
And change the 0 to 1..2 etc with jquery or what so ever.
What are your approaches on those views in which you dynamicly add multiple items?