Copy Current Record


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I searched the forum in vain for an answer to this.  How do I copy the current record of  BO to a new record in the same BO, reset a couple of values, navigate to that new record and allow the user to alter any necessary fields before saving?  This seems very simple.

Thanks,
Bill

Replies
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You cannot set a NULL value through the strong-typed property... and the .Item property (the indexer in C#, where you just use the []) uses those strong-typed properties.  In order to copy over the NULL values, you will need to bypass the strong-typed properties by using the .CurrentRow property like so:

In your foreach loop, change the:

partsBO1.Items(mCol.ColumnName) = mCurrentPart.Items(mCol.ColumnName);

to:

partsBO1.CurrentRow[mCol] = mCurrentPart.CurrentRow[mCol.ColumnName];

If you noticed, I used the column reference on the first and the column name on the second... that's because the fastest way to reference a column of a DataRow is by passing the column reference, but since the column belongs to the first BO and not the second, you have to use the name to reference the second one.  You could use the name on both, but then the DataRow would just use the name to find the column reference and then use it, so you might as well pass the column reference since you have it.

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Ben Chase (01/23/2008)

partsBO1.CurrentRow[mCol] = mCurrentPart.CurrentRow[mCol.ColumnName];

Sorry...I am a bit confused.  A DataRow object doesn't have a CurrentRow property, does it?  I'll try using the CurrentRow of the BO to see if that makes a difference.

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Woops, didn't look at the sample closely enough... didn't realize you were copying to a new record within the same business object... try this instead:

partsBO1.CurrentRow[mCol] = mCurrentPart[mCol];

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Ben Chase (01/24/2008)
try this instead:

partsBO1.CurrentRow[mCol] = mCurrentPart[mCol];

I changed just the BO side per your earlier suggestion.  It seems to work just fine.  I do have the second half looking like this, though:

mCurrentPart[mCol.ColumnName]

I am assuming that ColumnName is the default property to DataColumn object.  So leaving it there or removing it won't matter, eh?

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Bill Cunnien - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Bill Cunnien - 17 Years Ago
Bill Cunnien - 17 Years Ago
Paul Chase - 17 Years Ago
                         Excellent Paul! Thanks!! I am wondering, though, why no property...
Bill Cunnien - 17 Years Ago
                             Is it this? myBO .CurrentDataTable.Columns[myCol.ColumnName] The...
Bill Cunnien - 17 Years Ago
                                 Ran into another issue while testing...null values. These things just...
Bill Cunnien - 17 Years Ago
                                     Here is the offending code: private class...
Bill Cunnien - 17 Years Ago
                                         You cannot set a NULL value through the strong-typed property... and...
StrataFrame Team - 17 Years Ago
                                             [quote][b]Ben Chase (01/23/2008)[/b][hr] partsBO1.CurrentRow[mCol] =...
Bill Cunnien - 17 Years Ago
                                                 Woops, didn't look at the sample closely enough... didn't realize you...
StrataFrame Team - 17 Years Ago
                                                     [quote][b]Ben Chase (01/24/2008)[/b][hr]try this instead:...
Bill Cunnien - 17 Years Ago
Edhy Rijo - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Edhy Rijo - 17 Years Ago
                         There is not a framework function to do this....you are really better...
Trent L. Taylor - 17 Years Ago
                             Thanks again, will follow your advice.
Edhy Rijo - 17 Years Ago
                                 Here is my implementation of copying the current record into the same...
Edhy Rijo - 17 Years Ago
                                     Hi Edhy Thanks for your commentes. Can you post a sample of how to...
Juan Carlos Pazos - 16 Years Ago
                                         [quote][b]Juan Carlos Pazos (02/15/2009)[/b][hr]Hi Edhy Thanks for...
Edhy Rijo - 16 Years Ago
Juan Carlos Pazos - 16 Years Ago
Edhy Rijo - 16 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search