2

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?

1
  • 1
    I 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. Commented Oct 9, 2009 at 11:00

2 Answers 2

1

You have to recreate it from the form fields. The values you bound to the model for the GET are long gone.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.