0

I am using .Net MVC application and jquery.I have list of OrderLines returning to the View

Structure of OrderLine will be

public class OrderLine
    {    
        public string OrderNumber { get; set; }
        public string PartNumber { get; set; }
        public string QuantityOrdered { get; set; }
    }

I have to display in the view in a table as order lines. There will be button at the bottom. Onclicking the button, I need to group the order lines by OrderNumber and then submit each order('NOT each order line') as ajax request to the action method at a time.

Can any one tell, what is the best way to do this?

I need to post the data in the following structure

public class Order
{
    public string OrderNumber { get; set; }
    public List<OrderLine> orderLines { get; set; }
}

Action Method Signature will

Public ActionResult Update(Order order)

Thanks.

Bhaskar
  • 1,680
  • 7
  • 26
  • 40

1 Answers1

0

You can implement custom model binder with IModelBinder and convert your OrderLine posted values into Order parameter to Update Action method.

Example: http://buildstarted.com/2010/09/12/custom-model-binders-in-mvc-3-with-imodelbinder/

Best Practices when Implementing IModelBinder Best Practices when Implementing IModelBinder

Community
  • 1
  • 1
Priyank
  • 10,503
  • 2
  • 27
  • 25