PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Find out the changed rows in DataGridView

Reply

Find out the changed rows in DataGridView

 
Thread Tools Rate Thread
Old 14-12-2005, 09:13 AM   #1
=?Utf-8?B?TW9zaGU=?=
Guest
 
Posts: n/a
Default Find out the changed rows in DataGridView


Hi,

I have a DataGridView.
It's data source is a collection of objects (not a DB records).

After the user did some changes (Add/Delete/Update) I want to find out the
changed rows and the action made on them.

How to do it?


10x

  Reply With Quote
Old 14-12-2005, 06:04 PM   #2
Jim Wooley
Guest
 
Posts: n/a
Default Re: Find out the changed rows in DataGridView

Typically you will maintain this state inside of your custom objects. Add
and Update can be maintained with an internal IsNew and IsDirty flags.
Delete is a bit trickier as your object will have to tell it's collection to
flag it for deletion. When you are ready to persist your information, your
collection then will need to have the CRUD functions to persist the objects
based on their information.

Create: IsNew=True
Update: IsDirty and not IsNew
Delete: IsDeleted (in a deleted collection inside the hosting
collection?)

The downside of objects is that you have to do some of the plumbing
yourself. The upside is you get to do some of the plumbing yourself.

Jim
MCSD.Net

"Moshe" <Moshe@discussions.microsoft.com> wrote in message
news:6A5CBA83-C599-43AD-AFB2-855E684D269E@microsoft.com...
> Hi,
>
> I have a DataGridView.
> It's data source is a collection of objects (not a DB records).
>
> After the user did some changes (Add/Delete/Update) I want to find out the
> changed rows and the action made on them.
>
> How to do it?
>
>
> 10x
>



  Reply With Quote
Old 15-12-2005, 07:45 AM   #3
=?Utf-8?B?TW9zaGU=?=
Guest
 
Posts: n/a
Default Re: Find out the changed rows in DataGridView

Would it be easier if I create a DataTable from my object collection, bind it
to the DataGridView, and by that have all the "flags/state management" for
free?

Regards,
Moshe

"Jim Wooley" wrote:

> Typically you will maintain this state inside of your custom objects. Add
> and Update can be maintained with an internal IsNew and IsDirty flags.
> Delete is a bit trickier as your object will have to tell it's collection to
> flag it for deletion. When you are ready to persist your information, your
> collection then will need to have the CRUD functions to persist the objects
> based on their information.
>
> Create: IsNew=True
> Update: IsDirty and not IsNew
> Delete: IsDeleted (in a deleted collection inside the hosting
> collection?)
>
> The downside of objects is that you have to do some of the plumbing
> yourself. The upside is you get to do some of the plumbing yourself.
>
> Jim
> MCSD.Net
>
> "Moshe" <Moshe@discussions.microsoft.com> wrote in message
> news:6A5CBA83-C599-43AD-AFB2-855E684D269E@microsoft.com...
> > Hi,
> >
> > I have a DataGridView.
> > It's data source is a collection of objects (not a DB records).
> >
> > After the user did some changes (Add/Delete/Update) I want to find out the
> > changed rows and the action made on them.
> >
> > How to do it?
> >
> >
> > 10x
> >

>
>
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off