How do I dynamically add and remove line items from an ASP.NET MVC view?

Posted by Mike Roosa on Stack Overflow See other posts from Stack Overflow or by Mike Roosa
Published on 2009-03-27T15:25:23Z Indexed on 2010/04/15 12:03 UTC
Read the original article Hit count: 193

Filed under:
|
|

I have a PurchaseOrder model:

public class PurchaseOrder
{ 
    public string OrderNumber { get; set; }
    public string Customer { get; set; }
    public IList<LineItem> Lines { get; set; }
}

and a LineItem class:

public class LineItem
{ 
   public string PartNumber { get; set; }
   public int Quantity { get; set; }
}

What I want to do is on my view for the PurhcaseOrder Create action, I need a section for line items. The user should be able to add a new line, remove a line, then submit. One caveat is the PartNumber needs to be a dropdown list of valid parts.

What can I do to accomplish what I'm looking for?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about c#