I'm new to .Net development, and now are following NerdDinner tutorial. Just wondering if any of you would be able to tell me
What is the differences between ViewData and ViewModel
(all I know is they are used to pass some form of data from controller to view) and perhaps tell me on what situation should I use ViewData instead of ViewModel and vice versa
Thanks in advance!
Sally
What is ViewData ?
ViewData Sample
Controller Action method likes :
How to use ViewData on View ?
What is a ViewModel ?
Its like :
How to use ViewModel with MVC 3 ?
Domain Model
ViewModel
Controller Action Method
View - AddProduct.cshtml
Conclusion
ViewData:
In short, use ViewData as support data, such as a datasource to a SelectList.
ViewModel:
ASP.NET MVC ViewModel Pattern