Batch Updates from a Grid

Batch Updates from a Grid

am 12.04.2008 16:53:50 von rbrowning1958

Hello,

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,

Ray

RE: Batch Updates from a Grid

am 12.04.2008 20:01:01 von pbromberg

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
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net


"rbrowning1958" wrote:

> Hello,
>
> 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,
>
> Ray
>
>

Re: Batch Updates from a Grid

am 13.04.2008 10:56:00 von rbrowning1958

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?

Cheers

Ray

On Apr 12, 7:01=A0pm, Peter Bromberg [C# MVP]
wrote:
> 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 l=
ong
> as you have the correct insert, delete and update commands, it will proces=
s
> 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
> Site:http://www.eggheadcafe.com
> UnBlog:http://petesbloggerama.blogspot.com
> Short Urls & more:http://ittyurl.net
>
>
>
> "rbrowning1958" wrote:
> > Hello,
>
> > 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,
>
> > Ray- Hide quoted text -
>
> - Show quoted text -