• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 631
  • Last Modified:

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.


1 Solution
i would choose c) and update the database on the server only on user action (but that has to be clearly pointed to the user so they wont expect any change to be persistent unless pressing save/commit or something)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now