Back to Devexpress

LayoutItem.Controls Property

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

latest2.0 KB
Original Source

LayoutItem.Controls Property

Provides access to the ASPxFormLayout item’s collection of nested controls.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public ControlCollection Controls { get; }
vb
Public ReadOnly Property Controls As ControlCollection

Property Value

TypeDescription
ControlCollection

Object that represents a collection of nested controls.

|

Remarks

This example demonstrates how to find a layout item by its name and assign a value to a nested control:

View Example: Form Layout for ASP.NET Web Forms - How to find an item and access nested controls

Use the LayoutItem.Controls property to access a control placed in a layout item. The code sample below traverses through the collection of nested controls and assigns new values to the controls.

csharp
var layoutItem = (baseItem as LayoutItem);
foreach (var control in layoutItem.Controls) {
    ASPxEdit editor = control as ASPxEdit;
    if (editor != null)
        editor.Value = DateTime.Now;
}
vb
Private Sub SurroundingSub()
    Dim layoutItem = (TryCast(baseItem, LayoutItem))

    For Each control In layoutItem.Controls
        Dim editor As ASPxEdit = TryCast(control, ASPxEdit)
        If editor IsNot Nothing Then editor.Value = DateTime.Now
    Next
End Sub

See Also

LayoutItem Class

LayoutItem Members

DevExpress.Web Namespace