How to append without seeing save changes


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Greg,

You might want to try an ImportRow or LoadDataRow since you have a record from a DataTable that you are trying to import.  You can specify whether or not to preserve the row state (which is sounds like in this case you wouldn't want to.  It may look something like this:

LoadDataRow:

'-- Create the values collection that will match the structure of the data table
Dim myValues As Object() = New Object() {"Col1", 1234, DateTime.Now}

'-- Insert (or update) the row with the values that you want. 
MyBO.CurrentDataTable.LoadDataRow(myValues, LoadOption.OverwriteChanges)

ImportRow:

Me.CurrentDataTable.ImportRow(MyTable.Rows(0))

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Yeah, I tried that. I tried to call it right after calling AppendDataTable(). Unfortunately, the message already occurred. I.e. the bo is dirtied by the AppendDataTable call (apparently), and user is prompted to save changes before it returns.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
How about calling the BO.CurrentDataTable.AcceptChanges() in the AfterSave(). 

That may not be the best fix, but it may buy you some time. Wink

Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Yep. That is correct. The specific line that causes the BO to become dirty again (after all, it was just saved), is the AppendDataTable call.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Greg,

I understand that in the AfterSave() event you have code to update the current row? If this is the case, then the BO.IsDirty will be True causing the ask to save message, right?

Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I attempting to update the current row after a save (to get the values of some calculated columns from SQL Server). I have a method that uses AppendDataTable to update a single row. When this is called, the BO is dirtied and then I get a "do you want to save changes" message. From the user's perspective, what they see is:



- they save the record by clicking on "Save"

- Then they are asked if they want to save changes (duh, like, of course I do...I just clicked "Save"!)



Now, if they click Yes or No, it makes no difference, as the changes are fresh from the DB in any case. Cancel makes no sense as I'm doing this in AfterSave and the form has already put the BO into idle state.



So, what am I doing wrong here/how can I deal with this?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search