Let's say I have a product object (pretty much empty) and I bind it to a Product view. Then I click update in the view. In my CustomModelBinder my bindingContext.Model is always null on the update request. Is there a recommended way of me retrieving the prior model at this point or do I always have to recreate it?
-
1I think you'll hit a lot of issues where you believe the model sent to the view can be bound to the postback form view.. the reality is considerably different, for example.. you bind a collection a products for a 'products selection', but instead get back a collection of ints that represent the product ids.. in order for the postback to make this appear as products would mean it would need to do dataaccess and pull the products automatically regardless of their need.. I think you would begin to see perf issues with pulling considerable amounts of data just to suit a paradigm.meandmycode– meandmycode2009-10-09 11:00:57 +00:00Commented Oct 9, 2009 at 11:00
Add a comment
|
2 Answers
perhaps im not understanding your needs to use a CustomModelBinder, but did u concider Data Annotations Model Binder yet?
it even comes with (serverside) validation based on simple statements like [Required] which u can put right inside your model, see this