Skip to main content

Bind Form Layout to a Data Source

  • 2 minutes to read

Binding to a Data Source at Design Time

The FormLayout control can be used to edit or display data retrieved from a database via a data source control.

To bind a FormLayout to a data source control, click the smart tag of the FormLayout. In the invoked actions list, select an existing data source (if any), or create a new data source, from the Choose Data Source drop-down list.


The FormLayout control will automatically generate layout items for data source fields. The LayoutItem.FieldName property value of each layout generated is set to a corresponding data source field name.

The table below illustrates which DevExpress Data Editors are automatically nested into the FormLayout for different field value types. Nullable types are also supported.

Value Type Automatically Nested Data Editor
byte[] BinaryImage
String, Char TextBox
Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, Decimal SpinEdit
Enum ComboBox
Boolean CheckBox
DateTime DateEdit

You can add/delete/edit any layout item according to your needs (e.g., you can group layout items, add unbound layout items, customize automatically nested controls)

Binding to a Data Source at Runtime

To bind a FormLayout to a data source in code, define the data source via the DataSource or DataSourceID property, as shown in the code sample below.

protected void Page_Load(object sender, EventArgs e)
    if (!IsPostBack) {
        var category = dc.Categories.First(cat => cat.CategoryID == 1);
        ASPxFormLayout1.DataSource = category;

The FormLayout control will automatically generate layout items for all data source fields with the default design and layout at runtime.

The image below shows the look and feel of a FormLayout with layout items that are automatically generated at runtime.


See Also