If you are populating ViewData["categoryList"]
like this:
ViewData["categoryList"] = categories.Select(
category => new SelectListItem {
Text = category.Title,
Value = category.Id.ToString()
}).ToList();
then in your POST action, you can simply update your Product.Category property:
int categoryId;
int.Parse(Request.Form["Category"], out categoryId);
product.Category = categories.First(x => x.Id == categoryId);
or create custom ModelBinder for updating with UpdateModel():
public class CustomModelBinder : DefaultModelBinder
{
protected override void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, System.ComponentModel.PropertyDescriptor propertyDescriptor)
{
if (String.Compare(propertyDescriptor.Name, "Category", true) == 0)
{
int categoryId = (int)bindingContext.ValueProvider["tags"].RawValue;
var product = bindingContext.Model as Product;
product.Category = categories.First(x => x.Id == categoryId);
return;
}
base.BindProperty(controllerContext, bindingContext, propertyDescriptor);
}
}