ObjectDataSource general question

G

Guest

I have this problem and I am not able to find clear and good solution.
I have 2 tables, Order and OrderItems with relation 1:N.
I want to have 1 aspx page for editing, which will contain FormView for
Order and GridView for OrderItems. It isn't too important which control I
will use, but my question is:

How can I save all changes together.

I want user to have posibility edit header and details of order together. If
user click on Cancel button, all changes must be rejected. But
ObjectDataSource save changes into DB immediately, when user click on Row
update in GridView. But I don't want it.

Which is a right way to do it?

I think, this is general problem of all programmers who write ASP pages
which doesn't have only one flat editing (only one table record )

Jan
 
S

Sergey Gorbachev

Which is a right way to do it?

I use this way to solve similar problem (editing few tables):

1. The user works with a DataSet object during editing. He can add, edit,
remove records - all these acts work with cached data.
2. When the user clicks "Save" button, I start a transaction and save all
data in the database using adapters.
3. When the user clicks "Cancel" button, I simply clear the changes using
RejectChanges.
There are some complications because of table relations, but it works.
 
G

Guest

Thank frou your answer.
Which kind of caching do you use? Session?
Do you use ObjectDataSource?
 
S

Sergey Gorbachev

Which kind of caching do you use? Session?

No, we had some problems with storing datasets in Session. I use a static
collection of the the datasets:

private static Hashtable datasets = new Hashtable();

And access to it using current SesssionID

public NewsDataSet Dataset
{
get
{
NewsDataSet result =
(NewsDataSet)datasets[HttpContext.Current.Session.SessionID];
if (result == null)
{
result = new NewsDataSet();
datasets[HttpContext.Current.Session.SessionID] = result;
InitDataset(result);
}
return result;
}
}

NB! This code does not include clearing the cache from outdated data.
Do you use ObjectDataSource?

No, I use this class only for GridViews with the pager.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top