Solved

get all updated datagridview rows C#

Posted on 2009-05-06
14
1,013 Views
Last Modified: 2012-05-06
I have datagridview binding with table at database
User will edit rows and click save updates which call
SqlDataAdapter1.Update(dataset1);.
 Now I want to get all updates rows?
 I can't found datagridview.rowupdating event VS2005.
0
Comment
Question by:Rewaya
  • 9
  • 5
14 Comments
 
LVL 39

Expert Comment

by:abel
Comment Utility
To find the RowUpdating event in C#/VS, open the page in Design view, click the GridView and select the Events in the Properties window (in C# it is not possible to see a dropdown of all the events from the code window, like in VB). You can also do this manually, but this is easiest.

ScreenShot258.png
0
 

Author Comment

by:Rewaya
Comment Utility

 
The picture for datagrid not datagridview  and picture also for  web application and I am talking about desktop application
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
ouch!
apologies, I misread your q... I'll be back ;)
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
> The picture for datagrid not datagridview

actually: the ASP.NET GridView control, but never mind.
0
 

Author Comment

by:Rewaya
Comment Utility

And if it doesn't seen in the design view sure it will exist in properties of datagridview  in code when press ctrl+space
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
apparently this is not trivial for a variety of reasons. Luckily, someone came up with a solution already. The solution presented here is actually for a slightly different scenario, but it can just as well be used for your scenario, to keep track of modified / updated rows. It also discusses a few simpler alternatives if these apply to your situation: http://www.codeproject.com/KB/database/DataGridView2Db.aspx?display=PrintAll&fid=261351&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
> sure it will exist in properties of datagridview  in code when press ctrl+space

indeed so, but not for the handlers because they don't exist yet. Anyway, that earlier comment of me was about ASP.NET, please ignore that.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:Rewaya
Comment Utility

 
Ok I found this project before and don't help me.
0
 

Author Comment

by:Rewaya
Comment Utility
???????????
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
> Ok I found this project before and don't help me.
please elaborate. You do a post-fact update of the database, so you know your rows beforehand, or you do a on-event update of the database, in which case you can use the above link. What problem do you encounter, what errors do you get and what code did you use?

> ???????????? je n'ai pas compris...
0
 

Author Comment

by:Rewaya
Comment Utility

No I don't know which rows updated, how can I know that if the datagridview bind to table and any change automatically save by dataAdapter.update(dataset) ? And there is no event for row updated????
 
 On-event update of the database??? Is it built in event or what?
I read this article before and its related to binding datagridview row with database to save changes and there is nothing talk about my question inside it .  
 
0
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
Comment Utility
Apologies if I was unclear or misunderstood you, but I did mean the techniques mentioned there.

If I understand it correctly, you are using a dataset, which will contain a Tables collection. For each DataTable in the Tables collection you can use the GetChanges which will return another DataTable with only those that changed. For instance:

DataTable dtChanges = dataset.Tables(0).GetChanges(DataRowState.Modified);
which will return all modified rows for the first DataTable. You can use it on the dataset as well, which will work just the same: it will return all changes to that dataset:

DataSet dsChanges = dataset.GetChanges(DataRowState.Modified);
And if you want to test whether there were changes in the first place, you can use HasChanges in just the same way.

-- Abel --
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
> On-event update of the database??? Is it built in event or what?

that too. I meant the dataset.Tables(0).RowChanged event, which you can listen in to. That one was actually mentioned on the referring page, but I agree, I could've been a bit clearer on what I meant.
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
So, what was wrong with the solution? You didn't follow up, so I assumed all's fine. Please read the 10pts must guidelines of experts exchange. After all, we're all here to help, so please help us help you.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now