English 中文(简体)
ASP.NET和对象
原标题:
  • 时间:2009-04-20 13:22:28
  •  标签:

Let s say I have a class Person, with a string[] nickNames, where Person can have 0 or more nicknames stored. I want to create an asp.net page where a user can go and add/edit/delete nicknames.
Question is- how to i persist the Person object between postbacks? I query the DB and create the object then display it on a form, but then the user has the option to edit/delete fields of that object.. once the page is displayed with the fields of Person, how do I update that object with the changes the user made, to store to db?

Thanks!

问题回答

如果你的Person对象是可序列化的,你可以将它存储在ViewState中,如果不行,你可以将它粘贴到Session中,但听起来你可能对数据持久性总体缺乏理解。

Depending on your implementation, and whether you re coding this all by hand or using the built in DataSource/DataAdapter controls, theres a bunch of ways to do it.

You could have a look at some basic ASP.NET/ADO.NET Tutorials to point you in the right direction

将此翻译成中文:http://aspnet101.com/aspnet101/tutorials.aspx?id=17。 http://aspnet101.com/aspnet101/tutorials.aspx?id=17

再次查询该对象(您可以将其存储在会话变量中,但缩放不好),在 postback 上收集并应用用户的更改。





相关问题
热门标签