Access Variables in the Data Access Layer

Updated October 20, 2006
Iron Speed Designer V4.0 and later

Iron Speed Designer-applications maintain strict separation between the Presentation Layer (user interface) and the Data Access Layer.  While code customizations are typically added to an application’s Presentation Layer code-behind files, it is sometimes useful to add customizations in the Data Access Layer.  If your Data Access Layer customization depends on the value of a control which is not data bound, you can retrieve it with the help of the DataAccessSettings class.  The DataAccessSettings class can also be used to retrieve other useful information, such as the SignedInUserId and the SignedInUserName.

In the example below, the AddOrders.aspx page has an ASP.NET TextBox control.  The value of the text box cannot be accessed directly in the Data Access Layer, so the value is passed from the Presentation Layer to the Data Access Layer via the SystemUtils.SetDataAccessSettingsParameterValue method.

Step 1:  Handle the GetUIData() method in the RecordControl class of AddOrders.aspx.  Use the SetDataAccessSettingsParameterValue method to pass the value of the ASP.NET text box.

The SetDataAccessSettingsParameterValue method has two arguments.  The first argument is a key and the second argument is its value.  In the code below, “MYKEY” is the key and its value is “myKeyValue”.  The SetDataAccessSettingsParameterValue method can be called in any methods and, in this example, is called in the GetUIData() event in the AddOrders class.

The DataAccessSettings class is used to retrieve the value of the ASP.NET text box in the Data Access Layer.  Override the GetUIData() method in the OrdersRecordControl class, located in:

...\<App Folder>\App_Code\Orders\AddOrders.Controls.cs or .vb


public override void GetUIData()



     this.Page.SystemUtils.SetDataAccessSettingsParameterValue("MYKEY", "myValue");


Visual Basic .NET:

Public Overrides Sub GetUIData()


     Me.Page.SystemUtils.SetDataAccessSettingsParameterValue("MYKEY", "myValue")

End Sub

Step 2:  Add the following code in the OrdersRecord class in the Data Access Layer.  This code overrides the default constructor with a newly defined OrderRecord_InsertedRecord() method.  This new method gets the DataAccessSetting object which contains the key value.  In addition, the UserID and Password can be retrieved from this object.

The OrdersRecord class is located in:

...\<Application Folder>\App_Code\Business Layer\OrdersRecord.cs or .vb


public OrdersRecord()


     this.InsertedRecord+= new




private void OrdersRecord_InsertedRecord(object sender, System.EventArgs e)


     DataAccessSettings dataAccessSettingsObj = DataAccessSettings.Current;



          String myKey = (String)dataAccessSettingsObj["MYKEY"];

          String myUserID = dataAccessSettingsObj.SignedInUserId;

          String myUserName = dataAccessSettingsObj.SignedInUserName;


          //More code customization to fit your logic



Visual Basic .NET:

Public Sub New()


     AddHandler InsertedRecord, AddressOf Me.OrdersRecord_InsertedRecord

End Sub


Private Sub OrdersRecord_InsertedRecord(ByVal sender As Object, ByVal e As System.EventArgs)

     Dim dataAccessSettingsObj As DataAccessSettings = DataAccessSettings.Current

     If dataAccessSettingsObj.ContainsKey("MYKEY") Then

          Dim myKey As String = CType(dataAccessSettingsObj("MYKEY"),String)

          Dim myUserID As String = dataAccessSettingsObj.SignedInUserId

          Dim myUserName As String = dataAccessSettingsObj.SignedInUserName


     ‘More code customization to fit your logic


     End If

End Sub

Note: You can retrieve the value of a control in any of the events available in the OrdersRecord class based on where you want to add your business logic.  The events available in the OrdersRecord class are: