MVCxFormLayoutItemCollection<ModelType>.Add<ValueType>(Expression<Func<ModelType, ValueType>>) Method

Adds a layout item to the MVCxFormLayoutItemCollection<ModelType> collection and binds this item to the specified Model field.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v19.2.dll


public MVCxFormLayoutItem Add<ValueType>(
    Expression<Func<ModelType, ValueType>> expression
Public Function Add(Of ValueType)(
    expression As Expression(Of Func(Of ModelType, ValueType))
) As MVCxFormLayoutItem


Name Type Description
expression Expression<Func<ModelType, ValueType>>

An expression that identifies the object that contains the properties to edit or display.

Type Parameters

Name Description


Type Description

An MVCxFormLayoutItem object that is the newly added layout item.


Use the Add<ValueType> method to add a layout item bound to the specified Model field.

Refer to the Binding to Data and Item Manipulation topics to learn more.

If an item type (specified using the MVCxFormLayoutItem.NestedExtensionType property) is not set explicitly, the FormLayout creates a default item, applies your settings to it and uses a corresponding model property to determine a required type. Once the type is determined, the default Layout item is removed, and another item or a required type is created. Note that in this scenario, the FormaLayout gets access to the Model only during data binding, at which time your settings have been already applied to the default item. So, they do not apply to the new item again.

To solve this issue, you can do the following.

  1. Declare item type in item settings explicitly:

    groupSettings.Items.Add(itemSettings => {
        itemSettings.FieldName = "Description";
         itemSettings.NestedExtensionType = FormLayoutNestedExtensionItemType.TextBox; //required type here
        itemSettings.NestedExtensionSettings.Width = Unit.Percentage(100);
  2. Alternatively, use the overloaded Add method that directly accepts a Model property:

    groupSettings.Items.Add(m => m.Description, itemSettings =>
        itemSettings.FieldName = "Description";
        itemSettings.NestedExtensionSettings.Width = Unit.Percentage(100);
See Also