Skip to main content

How to: Specify the radio button list's state when it is located inside ASPxFormLayout

  • 2 minutes to read

This example demonstrates how to specify the ASPxRadioButtonList‘s state when it is located inside a Form Layout bound to data.

The data source bound to the ASPxFormLayout includes one record whose TestField field value is set to null (see the GetData method). To change the ASPxRadioButtonList’s state, handle the ASPxFormLayout.LayoutItemDataBound event. As a result, the ASPxRadioButtonList‘s ASPxListEdit.SelectedIndex is set to 0.

public partial class _Default : System.Web.UI.Page
    protected void Page_Init(object sender, EventArgs e) {
        formLayout.DataSource = GetData();
    private Person GetData() {
        return new Person()
            FirstName = "John",
            LastName = "Smith",
            Gender = Gender.Male,
            TestField = null
    protected void formLayout_LayoutItemDataBound(object sender, DevExpress.Web.LayoutItemDataBoundEventArgs e) {
        if (e.LayoutItem.FieldName == "TestField")
            if (e.NestedControlValue == null)
                foreach (var contrl in e.LayoutItem.Controls)
                    if (contrl is ASPxRadioButtonList)
                        (contrl as ASPxRadioButtonList).SelectedIndex = 0;
public enum Gender
    Male, Female
public class Person
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public Gender Gender { get; set; }
    public bool TestField { get; set; }