Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

get all updated datagridview rows C#

Posted on 2009-05-06
14
Medium Priority
?
1,192 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
ID: 24312323
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
ID: 24312389

 
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
ID: 24312396
ouch!
apologies, I misread your q... I'll be back ;)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 39

Expert Comment

by:abel
ID: 24312399
> The picture for datagrid not datagridview

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

Author Comment

by:Rewaya
ID: 24312405

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
ID: 24312465
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
ID: 24312475
> 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
 

Author Comment

by:Rewaya
ID: 24312644

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

Author Comment

by:Rewaya
ID: 24313286
???????????
0
 
LVL 39

Expert Comment

by:abel
ID: 24313305
> 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
ID: 24314109

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 1500 total points
ID: 24314348
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
ID: 24314447
> 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
ID: 24383505
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

824 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