本文介绍了ViewData和ViewModel在MVC ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是.Net开发的新手,现在是NerdDinner教程。只要想知道你有没有人能够告诉我
(我知道他们是用来从控制器传递一些形式的数据到视图),也许告诉我应该使用ViewData的情况
$ b
$ b class =h2_lin>解决方案 ViewData:
简而言之,使用ViewData作为支持数据,例如
ViewModel:
I'm new to .Net development, and now are following NerdDinner tutorial. Just wondering if any of you would be able to tell me
(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
解决方案
ViewData:
In short, use ViewData as support data, such as a datasource to a SelectList.
ViewModel:
ASP.NET MVC ViewModel Pattern
这篇关于ViewData和ViewModel在MVC ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!