views:

289

answers:

2

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!

A: 

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.

Cylon Cat
Hi, I am using SubSonic to generate the service layer. I have insert/update/delete - however I want to be able to edit the grid and click update without actually updating the datasource, but just updating the fetch I did, once I hit save on the form I want to call my save method on the service layer and pass in a reference to the object that the grid is bound to. I am having trouble though allowing an 'edit' command on the grid - as it is erroring saying I need something for 'RowEditing'. Thanks!
nelloomoo
Just to be sure, verify that you have an event handler for OnRowUpdating or OnRowUpdated on the grid. It probably wouldn't need to do much, but might still be required to exist. Since you're using an ORM, it does change the strategy a bit. In the object data source, your update method will get the data from the row, so what you do with it is up to you. When I did this using LINQ to SQL, I passed the data on to a LINQ entity, then called SubmitChanges() on the context. Depending on how SubSonic works, you might be able to update the data, but not save it.
Cylon Cat
(continuing) Or you might cache the data to update your SubSonic object later. Options really depend on your design, and on SubSonic's methods of operation. I can't help you with that, though, since I haven't used it. (I will add a SubSonic tag, though; it might get someone else's attention.)
Cylon Cat
A: 

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.

Jim Schubert