Solved

get all updated datagridview rows C#

Posted on 2009-05-06
14
1,111 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

636 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