Print Page | Close Window

Entity.RowState

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=677
Printed Date: 12-Apr-2026 at 6:24am


Topic: Entity.RowState
Posted By: Darren
Subject: Entity.RowState
Date Posted: 07-Feb-2008 at 9:03am
The problem i have is that my entity.rowstate does not seem to change even though i have edited the record.
 
I create 10 new blank entities using create method of my developer class.
They are then added to a new entitylist, which then in turn populates a datagridview.
 
I enter a value into one of my datagridview cells and jump to the next record.
At this point i would have thought that the rowstate changes.
 
Iam missing something here..?
 
 
 



Replies:
Posted By: jeffdoolittle
Date Posted: 07-Feb-2008 at 8:44pm

If you just created the entities, then they are still going to be in the "Added" state until you actually persist them.  Entities only go to the state "Modified" if they start in the state "Unchanged".  When you create the entities, they will remain in state "Added" until you either persist them (and state will be "Unchanged") or delete them (changing state to "Detached").

 



Posted By: Darren
Date Posted: 08-Feb-2008 at 6:32am
Thanks Jeff
 
I ended up creating a RowToPersist boolean property of the class, and set it value after any cell value changed in the DataGridView.
 
Then just save individual entities from the grid.
 
 


Posted By: jeffdoolittle
Date Posted: 08-Feb-2008 at 9:50am
Just a thought, you probably shouldn't be setting your boolean property based on cell values changing in your DataGridView.  This tightly couples your entity to the DataGridView.  Instead, you may want to consider overriding the OnPropertyChanged event in your entity and then set your boolean property in that method override.

--Jeff


Posted By: Darren
Date Posted: 11-Feb-2008 at 8:55am
Cheers Jeff
 
I think i will take that approach.



Print Page | Close Window