I'm not sure if I created this topic correctly, but basically I have a number of text fields and drop downs in my view and they are arranged in such a way as to look like a row. Some of the fields include Weight, Height, Length, etc. and the fields together compose a logical item. When the user clicks on a button next to the row it dynamically creates a new row of the same textfields and dropdowns, thus adding another "item" to the form. My question is how do you get the new rows to bind to a property in the model? So for example here are the fields in the model:
[Required]
[Display(Name = "Weight")]
public string Weight { get; set; }
[Required(AllowEmptyStrings = false)]
[Display(Name = "Class")]
public string Class { get; set; }
[Required]
[Display(Name = "Number of Units")]
public string NumberOfUnits { get; set; }
[Display(Name = "Length")]
public string Length { get; set; }
[Display(Name = "Width")]
public string Width { get; set; }
[Display(Name = "Height")]
public string Height { get; set; }
[Required(AllowEmptyStrings = false)]
[Display(Name = "Type")]
public string Type { get; set; }
If the user only uses the first row this is fine since it properly maps the textfields and dropdowns to the model, but adding an additional row of these elements won't work as far as the model is concerned. Any ideas on how to get the model to bind to the dynamically created elements? Thanks.