Back to Devexpress

LayoutItem.FieldName Property

aspnet-devexpress-dot-web-dot-layoutitem.md

latest3.0 KB
Original Source

LayoutItem.FieldName Property

Gets or sets the name of the database field assigned to the current layout item.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue("")]
public string FieldName { get; set; }
vb
<DefaultValue("")>
Public Property FieldName As String

Property Value

TypeDefaultDescription
StringString.Empty

A String value that specifies the name of a data field.

|

Remarks

Note

For ASP.NET MVC FormLayout.

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:
csharp
groupSettings.Items.Add(itemSettings => {
    itemSettings.FieldName = "Description";
     itemSettings.NestedExtensionType = FormLayoutNestedExtensionItemType.TextBox; //required type here
    itemSettings.NestedExtensionSettings.Width = Unit.Percentage(100);
});
  1. Alternatively, use the overloaded Add method that directly accepts a Model property:
csharp
groupSettings.Items.Add(m => m.Description, itemSettings =>
{
    itemSettings.FieldName = "Description";
    itemSettings.NestedExtensionSettings.Width = Unit.Percentage(100);
});

See Also

ASPxFormLayout.FindItemByFieldName

ASPxFormLayout.FindNestedControlByFieldName

LayoutGroupBase.FindItemByFieldName

LayoutGroupBase.FindNestedControlByFieldName

LayoutItem Class

LayoutItem Members

DevExpress.Web Namespace