Condividi tramite


AxForm

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

An AxForm component displays data from an AxDataSource in a form layout for a User Control. Typically, the AxForm component will contain AxMultiSection components to define the various sections for the form. If the form will not have any sections, the AxGroup component can be added directly to the form.

Properties

The AxForm component has the following properties:

Appearance

Property

Description

ShowButtonsInActionPane

When set to true, the buttons for the “Save and Close” and “Close” actions are displayed in the Action Pane Web Part on the page.

Behavior

Property

Description

AutoGenerateCancelButton

Indicates whether a cancel button is generated automatically for the form.

AutoGeneratedEditButton

Indicates whether an edit button is generated automatically for the form.

AutoGenerateInsertButton

Indicates whether an inert button is generated automatically for the form.

DefaultMode

The mode the form will be in when accessing data from the data source. The modes are ReadOnly, Edit, and Insert. The form will revert to this mode after a Cancel, Insert, or Update command.

DerivedControlMode

When a table hierarchy is used, specifies how the form will display fields from derived tables. If the fields do not exist for the entity type of the current record, the fields can be hidden or be shown in a disabled state.

EnableViewState

Specifies whether the control automatically saves its state for use in round-trips.

UpdateOnPostBack

Indicates whether the component is updated when a postback occurs.

Visible

Indicates whether the control is visible and rendered.

Data

Property

Description

Expressions

The expressions that are bound to properties of the control.

DataKeyNames

A comma-separated list of key fields in the data source.

DataMember

The table or view from the data set that is being used for the form. Typically, the _Current setting is used for AxForm components. This setting indicates the form is pointing to the current record for the data set.

DataSourceID

Specifies the AxDataSource component that will be used by the form to access data.

Misc

Property

Description

ID

The programmatic name of the control.

Mode

Specifies the current mode for the form. The modes are ReadOnly, Edit, and Insert.

Styles

Property

Description

CancelText

Specifies the text displayed in the Close command button for the form. When following Microsoft Dynamics AX guidelines for Enterprise Portal, use the word “Close”.

CommandRowStyle

The style applied to rows that contain command fields.

EditText

Specifies the text displayed in the Edit command button for the form. When following Microsoft Dynamics AX guidelines for Enterprise Portal, use the word “Edit”.

InsertText

Specifies the text displayed in the Insert command button for the form. When following Microsoft Dynamics AX guidelines for Enterprise Portal, use the words “Save and close”.

NewText

Specifies the text displayed in the New command button for the form. When following Microsoft Dynamics AX guidelines for Enterprise Portal, use the word “Create”.

UpdateText

Specifies the text displayed in the Update command button for the form. When following Microsoft Dynamics AX guidelines for Enterprise Portal, use the words “Save and close”.

ViewText

Specifies the text for the tab in view mode.

Events

The AxForm component has the events listed in the following table.

Event

Description

AxRowCreated

Occurs after a new row is created.

AxRowCreating

Occurs just before a new row is created.

DataBinding

Occurs when the server control binds to a data source.

DataBound

Occurs after the server control binds to a data source.

Disposed

Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested.

Init

Occurs when the server control is initialized, which is the first step in its lifecycle.

ItemCommand

Occurs when a button is clicked in the form control.

ItemCreated

Occurs after a new item has been created by the form control.

ItemInserted

Occurs after a new item has been inserted by the form control.

ItemInserting

Occurs before the new item has been inserted by the form control.

ItemUpdated

Occurs after an item has been updated by the form control.

ItemUpdating

Occurs before an item has been updated by the form control.

Load

Occurs when the server control is loaded into the System.Web.UI.Page object.

ModeChanged

Occurs after the mode of the form has changed, such as from ReadOnly mode to Edit mode.

ModeChanging

Occurs just before the form mode has changed, such as from ReadOnly mode to Edit mode.

PageIndexChanged

Occurs after the page index has changed for the form.

PageIndexChanging

Occurs just before the page index has changed for the form.

PreRender

Occurs after the System.Web.UI.Control object is loaded by prior to rendering.

Unload

Occurs when the server control is unloaded from memory.

Create and Update behavior

When the user clicks the "Save and close" button on the action pane for the User Control, the AxForm component will fire the appropriate events to create or update the data for the form component. If you are using additional components in the User Control, such as an AxGridView, you may have to explicitly invoke the events for these other components to have their create or update operations performed when the user clicks "Save and close".

For example, the following C# code is the event handler for the ItemUpdating event of an AxForm component named EPSalesTableEdit. In this code, the UpdateRow event for an AxGridView component is called explicitly to ensure that any changes on the current row of the grid are saved.

void formEPSalesTableEdit_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
    try
    {
        // Save the last unsaved line if any
        if (gridEPSalesLineEdit.EditIndex != -1)
        {
            this.gridEPSalesLineEdit.UpdateRow(gridEPSalesLineEdit.EditIndex, true);
        }

        //Other code…
    }
    catch (System.Exception ex)
    {
        AxExceptionCategory exceptionCategory;
        // This returns true if the exception can be handled here
        if (!AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory))
        {
            // The exception is system fatal - in this case we re-throw.
            throw;
        }
    }
}