I am new to .NET MVC and am trying to figure out forms, I think I am on the right track but I am stuck trying to figure out how to create a form based off of a class that has an ObservableCollection<> of another class, for example:
public class Items
{
public string Notes { get; set; }
public ObservableCollection<LineItem> LineItems { get; set; }
}
and Line Items is something like:
public class LineItem
{
public string ItemNumber { get; set; }
public string QTY { get; set; }
}
From what I understand I should create an instance of Items in the controller and pass that to my view
return View(new Items());
Then on my view I use HTML helpers to create the form and when I submit the form, the model Items is sent back to the controller with filled out data. How do I go about having multiple LineItems in my view that bind to the ObservableCollection<> in my Model ? Let's say they need 2 LineItems, is there a programmatic way to show the inputs for public ObservableCollection<LineItem> LineItems multiple times, as an ObservableCollection is typically more than one instance of the class. I am using .NET MVC C# with Razor syntax.