Cache, Cookies and Session Variables
Save Information in Session Variable

Description
This customization demonstrates how to save information in a session variable when updating a record.
Variables
Button Control
Select the button
Table
Select the table
Primary Key
Select primary key column in the record control class
Applies to
Page class
Code
 
/// 
/// Override the CommitTransaction, retrieve the id of the
/// saved record and store it in session.
/// 
public override void CommitTransaction(object sender)
{

    // Call base.CommitTransaction()which will save the changes made by user
    base.CommitTransaction(sender);
    System.Web.UI.WebControls.LinkButton myButton = ((System.Web.UI.WebControls.LinkButton)(sender));

    // Check to see if the button that got clicked is the save button.
    // This is done because ID of a record should be stored
    // in session only if save button is clicked.
    if ((myButton.Parent.ID == "${Button Control}"))
    {
        // Save information in a session
        // Store the ID in session

        this.Page.Session["UpdatedRecordID"] = this.${Table}RecordControl.GetRecord().${Primary Key}.ToString();  

        // Save other fields in session
        // this.Page.Session["UpdatedRecordName"] = this.${Table}RecordControl.GetRecord().${FieldName}.ToString();
    }
}
 


  Privacy Statement