Solved

get all updated datagridview rows C#

Posted on 2009-05-06
14
1,066 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
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!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Input parameteres to DragOver 2 34
Visual Studio npm 1 29
JQuery Detecting page post back 6 19
Nested forach loop to linq 3 24
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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 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