How to edit gridview "offline" then update later?

Here's what I have: A webform with a gridview and a form section to "add" records. The gridview is databound to an objectdatasource. It has an edit and delete button. A "submit changes to database" button is at the bottom of the form (this actually submits the adds, edits and deletes to the db).

Here's what I want: For the user to be able to add, edit and delete records/gridview. BUT, it will NOT actually update the database UNTIL the button is pressed. So, they are really editing the data OFFLINE then "syncing" it, in a way, with the database.

Questions: How can I go about letting them modify the data "offline"? How can I update the database with the changes most efficiently?
LVL 9
RobertNZanaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Si_HibbardCommented:
Get a datatable from the DB - same as you would when you get a datatable and bind it to a control in codebehind.

Store the datatable in a session, when the user updates stuff, update the datatable stored in the session.

When you want to update the actual DB with the changes, update it from the datatable you have stored in your session.
0
RobertNZanaAuthor Commented:
CodeCruiser: Thanks, but that link doesn't help my situation at all.

Si_hibbard and others: So you are saying to retrieve the dataset into a session var and bind the gridview to this? Then update this dataset (from the session var)? If so how can I "sync" the 2 datasets the easiest, most efficient way? I'm sure I dont need to loop thru each record 1 by 1. Is there an isdirty, etc... way to sync it? I'm sure there is.
0
Si_HibbardCommented:
The first step is easy, just get the datatable, bind it to the gridview, and also store it in a session.

On updates, you need to handle yourself, load the datatable from the session, update it, rebind it to the gridview and save it back in the session.

On complete you then need to update the DB from the saved session.

How you do these depends on how you are building your code - i.e. using a data access layer (datasets) or whatever.

I did find this link, it may be useful or not -> http://www.dotnetspider.com/resources/20462-Bind-Gridview-from-Session-Then-Edit-Update.aspx

Maybe you can search a bit more on 'binding gridview from session', 'storing datatable in session', 'sql update from datatable session' to give you some ideas to suit your solution.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.