Skip to content

elenapeskova/aspxformlayout-how-to-get-an-item-using-finditembypath-method-e4579

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

[Run Online]

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

FormLayout Items

Overview

Create the Form Layout control, add item and group objects, and specify their Name properties.

<dx:LayoutGroup Caption="Group1" Name="Group01">
    <Items>
        <dx:LayoutItem Caption="LayoutItem011" Name="LayoutItem011">
            <LayoutItemNestedControlCollection>
                <dx:LayoutItemNestedControlContainer ID="layoutContainer1" runat="server">
                    <dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Width="170px" />
                </dx:LayoutItemNestedControlContainer>
            </LayoutItemNestedControlCollection>
        </dx:LayoutItem>
        <!-- ... -->
    </Items>
</dx:LayoutGroup>

To find a layout item by its name, call the control's FindItemOrGroupByName method and pass the item's Name property value as a parameter.

LayoutItemBase baseItem = layout.FindItemOrGroupByName(ASPxComboBox1.Value.ToString()) as LayoutItemBase;

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

var layoutItem = (baseItem as LayoutItem);
foreach (var control in layoutItem.Controls) {
    ASPxEdit editor = control as ASPxEdit;
    if (editor != null)
        editor.Value = DateTime.Now;
}

Files to Review

Documentation

About

.NET, ASP.NET Web Forms, Navigation, Layout & Multi-Purpose Controls

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • ASP.NET 82.5%
  • C# 17.5%