Hi Im stuck on how to do this the best way. In my case I got a Product and it got a Manufacturer Object.
So what I do is I pass the product to the view to edit. But when I do the save I look at the product object and Manufacturer is now null. I tried to do a hiddenfor for the Manufacturer Object like I do with id for the product, but that wont work. How is the best way to do this?
hope you get what I mean?
public ActionResult EditProduct(int id)
{
var product = _productService.GetById(id);
return View(product);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditProduct(Product product)
{
//_productService.SaveOrUpdate(product);
TempData[Message] = product.ProductName + " have been saved";
return RedirectToAction("Products");
}
EDIT
Product Object
public virtual int Id { get; set; }
public virtual string ProductName { get; set; }
public virtual Manufacturer Manufacturer { get; set; }