Batch Updates from a Grid




Doing my first ASP project so this may be simple and I'm missing
something...could someone please calrify this for me?

1. I have an ASP page with a grich which allows user to add, edit and
delete records.

2. The grid is linked to an objectdatasource which points to a
business class

3. The business class has the usual add/edit/ delete methods which in
turn pass these requests through to a tableadapter which I generated
using the data set designer.

4. The table adapter is using stored procedures to do the insert /
edit / delete

5. In this scenario the grid is adding records / deleting etc.
directly to the database. I want this to behave more like a windows
style grid where the updates are not sent to the actual database until
the I execute the update method.

Is there a standard way of doing this? My initial thoughts were to
have the business class's update / insert / delete methods work on a
datatable which I create from the initial select, then have an update
method that jsut calls teh table adapters update method, but how this
works is making my head spin a little. Presumably I'll have to have
the datatable sent to and from the client as part of the session - is
this correct?

I'm guessing in general this is not a good idea but in this case there
will be at msoat 20 records or so.

If I'm correct and this is the best way to go, I guess my business
class will have to retrieve the dataTable from the session for each
delete / update / insert operation?

Cheers in advance,




Peter Bromberg [C# MVP]

Essentially, you can pass a DataTable that has any combination of new,
deleted and / or modified rows into a DataAdapter's Update method and as long
as you have the correct insert, delete and update commands, it will process
all the rows at once.

So really all you need to do is engineer the way to do this that is most
comfortable for your situation.
-- Peter
Short Urls & more:




Hi Peter,

Thanks for replying. I know about the update method and how it can
batch things for you but I suppose I'm a little unclear as to how this
works in a web environment. If my business object adds things to a
datatable or a dataset then updates when requested, rather than
directly to the databse, where does the datatable / dataset get
stored? Doesn't it need to be part of the session?



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