Link to home
Start Free TrialLog in
Avatar of RichardKnight
RichardKnight

asked on

Best way to add/modify/delete data in a datagrid

I have a Visual Studio 2008 .NET 3.5  web application that uses datagrids. I need to add/modify/delete rows in those datagrids. Currently when a row is added, the database is hit there and then, i.e. I don't store a number of rows to be added and then do a batch insert.

At the moment a datagrid will have a pagesize of e.g. 8. i.e. the database loads 8 records at a time and is hit every time a datagrid page change occurs. Would I be better off in terms of time to:

a) Load all of the datagrid data into a dataset (could be 1000's of rows) and upon adding a row to the dataset just update the database with that row on a row by row basis (not a batch insert)?

b)  Stick with the paging method above i.e. load a new page from the database every time. Upon adding  a new row simply update the database with that row?

c) Load all of the datagrid data into a dataset (could be 1000's of rows) and upon adding a row to the dataset don't update the database until a commit button is pressed therefore allowing for a batch update of rows?

d) Have a separate add/modify screen so that new data can be added to a smaller dataset (the add/modify dataset) and keep the paging as above so that for e.g. if you are looking for a row in the datagrid to update you find it by whatever method (search or page number) with the requisite database hit. Then you modify the row and that modification is placed in the smaller add/modify dataset and can be committed whenever. This would avoid the loading of all of the datagrid data into a dataset.

I am leaning towards d) but not in a position to implement it yet (time!) therefore which of a) to c) would be the best way forward in the interim. c) would be the neatest method but would there be a large hit in terms of performance - there are several datagrids on a page and they would all be implemented using this method.

Thanks,

Rich.
ASKER CERTIFIED SOLUTION
Avatar of Agarici
Agarici
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial