I have a ViewModel with several properties containing Collections for populating the DropDowns in form. In get Action, these properties are filled, and then view is properly rendered.
When user sumbits form, th开发者_StackOverflow中文版en in Post action my ViewModel contains all data filled in form, but all collection properies are null, because browser doesn't send them. That's ok, when ModelState is valid, so i don't need them anymore. But, when the ModelState is not valid I need to show the form again for correcting the errors.
Is MVC storing these collections temporary anywhere, co the ViewModel properties can be easily filled with same values as in get action, or do I have to populate them manually (from cache or new query to db) ?
I thought, that MVC stores original values, so they can be used during validation in post action, but I can't figure it.
thanks
You could probably use a custom ModelBinder
Check out this post by Jimmy Bogard. It isn't exactly what you need, but it can give you some ideas.
精彩评论