Appframe Knowledge Base


1 hits
0

How to copy a row in afDataObject

' Copy all items from the current row into an array
Dim vItems As Object = MyDataObject.CurrentRow.ItemArray

' Adds a new item to the dataobject
MyDataObject.AddNew()

' Saves the PrimKey value from the newly added row
Dim vPrimKey As String = MyDataObject.CurrentRow("PrimKey").ToString()

' Moves all items to the new row
MyDataObject.CurrentRow.ItemArray = vItems

' Makes sure the PrimKey isn't duplicated and sets the stored PK reference
MyDataObject.CurrentRow("PrimKey") = vPrimKey

' For each column you don't want to include in the new row remove it by setting DBNull.Value
MyDataObject.CurrentRow("Updated") = DBNull.Value
MyDataObject.CurrentRow("UpdatedBy") = DBNull.Value
MyDataObject.CurrentRow("Created") = DBNull.Value
MyDataObject.CurrentRow("CreatedBy") = DBNull.Value

' Finally save the new row
MyDataObject.EndEdit()

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)