收录日期:2019/10/22 14:33:13 时间:2009-11-11 05:04:07 标签:c#,asp.net,subsonic,objectdatasource

I have a GridView which I am binding to my service layer.

I want to be able to allow the user to edit the grid, but I do not want to save the grid as the user is clicking update on each row. I would like to update all of the edited/added/deleted rows when the 'save' button for my entire form is submitted.

I have my service layer configured, and the GridView calls update on a per row edit basis, however I want that to happen all at the end when clicking save.

How can I maintain my ObjectData sources references to update, insert, delete but instead of on a per row basis be able to call a save on everything all at once?

Thanks!

If you're using an object data source, then the behavior of the object bound to the object data source is up to you; it doesn't have to save to the database right away. If you want, you can build the database commands you want to execute, then cache them somewhere until the save button is clicked.

Object data source objects should be static or stateless, so you can't cache there. However, this sounds like a reasonable use of Session cache.

Here is a tutorial on asp.net/learn for wrapping updates in a transaction:

http://www.asp.net/Learn/Data-Access/tutorial-63-cs.aspx

The example uses GridView and ObjectDataSource. This may or may not be useful with subsonic, but it may help others with a similar problem.