If the new primary key value is created programmatically, according to a certain rule, on the server, then it is done in the BeforeUpdateRow event. First, a new primary key value is allocated or calculated in code (maybe using a stored procedure or other mechanisms) and assigned to the corresponding field(s) in the Row argument. Thus the temporary key value originally present in Row is substituted with the final, real value. When DataObjects for .NET inserts the row into the database after the event, it uses the new value. When it then sends the row back to the server for refresh (see Changing Data as a Result of Update (Refresh)), the new value is sent to the client. Having received the new value, the client substitutes the temporary value with the real one.
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub table_Orders_BeforeUpdateRow(ByVal sender As Object, ByVal e As C1.Data.RowUpdateEventArgs) Handles table_Orders.BeforeUpdateRow e.Row["OrderID"] = AllocateNewRowID(); End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void table_Orders_BeforeUpdateRow(object sender, C1.Data.RowUpdateEventArgs e) { e.Row["OrderID"] = AllocateNewRowID(); } |