FormView Events

Other usage samples: Simple FormView | Editable Form | Events | Styles |

This sample demonstrates the ModeChanged and ItemCommand events on the FormView control.


ModeChanged & ItemCommand

Click Edit to switch modes, then Update or Cancel. Both events are logged below.

Widget Viewer
Event Log:

No events yet — interact with the FormView above.


Code Example

<FormView ModeChanged="HandleModeChanged"
          ItemCommand="HandleItemCommand"
          ItemType="Widget" Context="Item">
    <ItemTemplate>
        <Button CommandName="Edit" Text="Edit" />
        <Button CommandName="CustomAction" Text="Custom" />
    </ItemTemplate>
    <EditItemTemplate>
        <Button Text="Update" CommandName="Update" />
        <Button Text="Cancel" CommandName="Cancel" />
    </EditItemTemplate>
</FormView>

@code {
    void HandleModeChanged(FormViewModeEventArgs e)
    {
        // e.NewMode — ReadOnly, Edit, or Insert
    }

    void HandleItemCommand(FormViewCommandEventArgs e)
    {
        // e.CommandName — "Edit", "Update", "Cancel", or custom
    }
}