Reputation: 1090
I have been working with mvc for a little while now, but now im stuck with a problem that I didnt see come :) The method in the controller returns a view with a model containing a Customer and Booking:
public class CustomerAndBooking
{
public Customer customer { get; set; }
public Booking booking { get; set; }
}
In my view i fill out the fields from the Booking. Very simple. The Customer is just being showed in the view and not modified. When I submit the view, the Booking in the model have all the data I choosed from the view, but the Customer is null?? I was hoping that the Customer would still be as it were when the controller first created the model. How do I make it so my model is still intact when submitting the view??
Upvotes: 0
Views: 46
Reputation: 7455
You can do this by add to view:
@Html.HiddenFor(m => m.customer);
Upvotes: 1