开发者

Problem of viewstate in MVC Architecture?

We add mutiple data of text boxes to gridview that would not update database untill user press add button...here i had tried to use viewstate but the it become null when any other event occures in MVC Arch...so this 开发者_如何转开发the problem.can i use dataset...if yes than how??? thank you in advance...


You don't use viewstate in MVC. You can use DataSet of course, but controls that relied on viewstate in webforms will not work.


MVC Do not have viewstate and session but you can use TempData Object instead of viewstate. in your controller you can bind like this TempDate["MyKey"]="My Value" and in the next request you can get your value in action like String s=TempData["MyKey"]


I recommend you to use strongly typed views. Here you can attach you model properties with the view elements, so that when you post back, the model object will contain all the posted values.

You can also use Display Templates, to iterate the test boxes and attach / pass model properties

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜