Record Control code example

#Region "Section 1: Place your customizations here."

    Public ClassCustomersRecordControl

        InheritsBaseCustomersRecordControl

    End Class
#End
Region

 

#Region "Section 2: Do not modify this section."

    Public ClassBaseCustomersRecordControl

        InheritsMyApp42.UI.BaseApplicationRecordControl

 

        Protected Overridable SubControl_Init() Handles MyBase.Init

        End Sub

 

        Protected Overridable SubControl_Load() Handles MyBase.Load

            AddHandler Me.Address.TextChanged, AddressOfAddress_TextChanged

            AddHandler Me.City.TextChanged, AddressOfCity_TextChanged

        End Sub

 

 

        Public Overridable Sub LoadData()

            Dim wc AsWhereClause = Me.CreateWhereClause()

            Dim recList() AsCustomersRecord = CustomersTable.GetRecords(wc, Nothing, 0, 2)

            Me.DataSource = CustomersTable.GetRecord(recList(0).GetID.ToXmlString(), True)

        End Sub

 

        Public Overrides Sub DataBind()

            MyBase.DataBind()

            SetAddress()

            SetCity()

        End Sub

 

        Public Overridable SubSetAddress()

        End Sub

 

        Public Overridable Sub SetCity()

        End Sub

 

        Public Overridable FunctionEvaluateFormula() As String

        End Function

 

 

        Public Overridable Sub SaveData()

            Me.LoadData()

            Me.Validate()

            Me.GetUIData()

            If Me.DataSource.IsAnyValueChanged Then

                Me.DataSource.Save()

            End If

        End Sub

 

        ' To customize, override this method in CustomersRecordControl.

        Public Overridable SubGetUIData()

            GetAddress()

            GetCity()

        End Sub

 

 

        Public Overridable SubGetAddress()

        End Sub

 

        Public Overridable Sub GetCity()

        End Sub

 

        Public Overridable FunctionCreateWhereClause() AsWhereClause

        End Function

 

        Protected Overridable SubControl_PreRender…) Handles MyBase.PreRender

            ' PreRender event is raised just before page is being displayed.

            Try

                DbUtils.StartTransaction()

                    Me.LoadData()

                    Me.DataBind()

            Catch ex As Exception

                Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)

            Finally

                DbUtils.EndTransaction()

            End Try

        End Sub

 

    End Class

#End Region