简体   繁体   中英

how to recognize newly added rows directly to datagridview - c#

I have bound a datatable to a datagridview and allowed the user to delete update , and insert new records directly to this datagridview

Now I want to know how do I recognize newly inserted row/rows ?

I want to get new row/rows and delete update , or insert them into SQL server database.

How can I do it ?

Thanks

You can do it in 2 different ways - depend on your use case:

1st: Server side

Use this concept if you want to track the changes with multiple session per user, submit all changes to server side and track the changes datetime and save status.

2nd: Client side

Use this concept if you want to track the changes on client side regardless of the multi-session per user, basically, add 1 extra column to track the changes history -better to keep it hidden-

You can look into the DataTable.GetChanges method https://msdn.microsoft.com/en-us/library/thc1eetk

or better look into the DataAdapter.Update method https://docs.microsoft.com/en-us/dotnet/api/...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM