[RESOLVED]Post Gridmvc as well as form data on HTTPPOST

Hi i have an form in mvc, i nedd to save data in two table in single httppost like saving one to many relationship data eg order and order details table. how do i achive this in view and post the data to controller i m able to get the order data but i cannot
retive the orderdetails data on submit button of form plz help thamks

Hi p.priyank,

Thanks for your post.

If you are using Entity Framework, You can refer to the following code snippet according to your requirement to modify these code and use it

var context = new MyDBModelContext();

tblOrder order= new tblOrder()
{
    FileName = theFileName,
    Description = theDescription
};

context.tblOrderS.Add(order);
context.SaveChanges();

tblOrderDetails details = new tblOrderDetails()
{
    OrderID = order.OrderID,
    Actor = theActor,
};

context.tblOrderDetails.Add(details);
context.SaveChanges();

Hope this can be helpful.

Best Regards,

Eileen

Leave a Reply