This example demonstrates how to find a layout item by its name and assign a value to a nested control.
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;
}
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
(you will be redirected to DevExpress.com to submit your response)