Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Scheduler
  [Collapse]Site Navigation and Layout
   [Expand]Product Information
   [Collapse]Form Layout
     ASPxFormLayout Overview
    [Collapse]Concepts
     [Collapse]Binding to Data
       Binding to Data Overview
       Binding to a Data Source
       Binding to a Single Object
      Item Manipulation
      Adaptivity
    [Expand]Visual Elements
   [Expand]Menu
   [Expand]Navigation Bar
   [Expand]Page Control and Tab Control
    Panel Overview
   [Expand]Ribbon
   [Expand]Site Map Control
   [Expand]Splitter
   [Expand]Tag Cloud Control
   [Expand]Title Index
   [Expand]TreeView
  [Expand]HTML Editor
  [Expand]Gauges
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Binding to a Single Object

This tutorial describes how to bind the FormLayout control to a single object. You will learn how to use the FormLayout to edit a record from a data table, retrieved from a database via LINQ to SQL.

To bind FormLayout to an object, follow the steps below.

  1. Drop a FormLayout onto the form. Click the smart tag of the FormLayout, and select Edit Layout in the invoked actions list. In the invoked ASPxFormLayout Items Editor, click Retrieve Items.

  2. In the Choose Data Type… dialog, select the type of objects whose fields will be edited/displayed within the FormLayout. In this example, the Employee class is selected.

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

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

    Value TypeAutomatically Nested Data Editor
    byte[] BinaryImage
    String, CharTextBox
    Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, DecimalSpinEdit
    EnumComboBox
    BooleanCheckBox
    DateTime DateEdit

    The image below illustrates automatically generated fields for the Employee class used in this tutorial.

  4. 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, etc. Follow the Item Manipulation topic to learn how to customize the layout of items and groups.

    The image below illustrates how the position of layout items can be changed.

  5. Define a data source within the code-behind. When updating data source values, retrieve new values via the ASPxFormLayout.GetNestedControlValueByFieldName method. The code sample below demonstrates how to bind FormLayout to a data source via LINQ to SQL, and update values in the database when an end-user submits the form to the server.

    Note

    You can also bind the FormLayout control to a list of objects (IEnumerable<T>, IQueryable<T>, etc.). In this case, the first element in the list is automatically retrieved.

The image below shows the result.

Expanded See Also

Is this topic helpful?​​​​​​​