get all updated datagridview rows C#

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.
RewayaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
abelConnect With a Mentor Commented:
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
 
abelCommented:
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
 
RewayaAuthor Commented:

 
The picture for datagrid not datagridview  and picture also for  web application and I am talking about desktop application
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
abelCommented:
ouch!
apologies, I misread your q... I'll be back ;)
0
 
abelCommented:
> The picture for datagrid not datagridview

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

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
 
abelCommented:
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
 
abelCommented:
> 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
 
RewayaAuthor Commented:

 
Ok I found this project before and don't help me.
0
 
RewayaAuthor Commented:
???????????
0
 
abelCommented:
> 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
 
RewayaAuthor Commented:

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
 
abelCommented:
> 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
 
abelCommented:
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
All Courses

From novice to tech pro — start learning today.