Get ID of Saved Record in PostCommitTransaction
Database schemas usually issue record ID’s by calling newid() or by using identity fields in your database. You can retrieve the ID of a newly created record in the PostCommitTransaction event of the Page class.
- Pooja Daga, Technical Support Engineer, Iron Speed, Inc.

April 12, 2006
Iron Speed Designer V3.2

Procedure
Database schemas usually issue record ID’s by calling newid() or by using identity fields in your database. You can retrieve the ID of a newly created record in the PostCommitTransaction event of the Page class. The record’s ID is only available after the transaction has been committed, so the PostCommitTransaction event is the best place to retrieve the ID. In the example below, the PostCommitTransaction event is handled in the AddOrdersPage class and the record’s ID is retrieved.

The AddOrdersPage.aspx.cs file containing the Page class is typically located in:

...\<Application Folder>\Orders\AddOrdersPage.aspx.cs

Add the code customization below to retrieve the new record’s ID.

C#:

public AddOrdersPage()
{
    this.PostCommitTransaction += new
 
    BaseClasses.ITransactionalComponent.PostCommitTransactionEventHandler(Page_PostCommitTransaction);
}
 
private void Page_PostCommitTransaction(object sender, EventArgs e)
{
    OrdersRecord rec = this.OrdersRecordControl.GetRecord(false);
    int tempId = rec.OrderID;
    //Do your processing here
}

Visual Basic .NET:

Private Sub Page_PostCommitTransaction(ByVal sender As Object, ByVal e As System.EventArgs)
    Handles MyBase.PostCommitTransaction
 
    Dim rec As OrdersRecord = Me.OrdersRecordControl.GetRecord(False)
    Dim tempId As Integer = rec.OrderID
    ‘Do your processing here
End Sub

About the Author
Pooja Daga
Technical Support Engineer, Iron Speed, Inc.

Pooja has experience developing Web applications using .NET technology. She started her career with PCS, a leading software services company headquartered in India and has been with Iron Speed since 2005.

Pooja holds an M.S. degree in Computer Application and a B.S. degree in Electrical engineering from Maharaja Sayajirao University in India.



  Privacy Statement