How record values entered in a form to a List or collection in ASP MVC [closed]

Generally, you would use a collection when you have a list of similar things that can be selected (i.e., a multi-select list box). The M in MVC is the data model. It doesn’t really work without that.

You should create a class that contains the fields you need and then pass that class to your view, e.g.:

public class UserGammeModel {
  public string PosteItems
  public string NobreDePassage { get; set; }
  public string Position { get; set; }
  public Gamme PostePrecedent { get; set; }
  public Gamme PosteSuivant { get; set; }

Use whatever object types make sense for your model class properties–the more strongly-typed, the better!

Then pass your model to the view in a controller GET action method:

public ActionResult Save() {
  return View(new UserGammeModel());

Finally, handle the posted values in a controller POST action method:

public ActionResult Save(UserGammeModel model) {
  // Do stuff with posted model values here

Browse More Popular Posts

Leave a Comment