Back to Devexpress

ASPxRadioButtonList Class

aspnet-devexpress-dot-web-6cda5f0b.md

latest8.4 KB
Original Source

ASPxRadioButtonList Class

Represents a group of radio button editors that allow one option from several to be selected.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public class ASPxRadioButtonList :
    ASPxCheckListBase
vb
Public Class ASPxRadioButtonList
    Inherits ASPxCheckListBase

Remarks

The ASPxRadioButtonList control represents a single-selection radio button group that can be dynamically generated through data binding or populated manually. It contains an ASPxListEdit.Items collection with members that correspond to individual items in the list. To specify the selected item the control’s ASPxListEdit.SelectedItem or ASPxListEdit.SelectedIndex property can be used. When the selected item changes within the ASPxRadioButtonList control, the ASPxListEdit.SelectedIndexChanged event is generated.

Create a Radio Button List

Design Time

The ASPxRadioButtonList control is available on the DX.25.2: Common Controls toolbox tab in the Microsoft Visual Studio IDE.

Drag the control onto a form and customize the control’s settings, or paste the control’s markup in the page’s source code.

aspx
<dx:ASPxRadioButtonList ID="radioButtonList" runat="server">
    <Items>
        <dx:ListEditItem Value="Yes, this time only" />
        <dx:ListEditItem Value="No, not this time" />
        <dx:ListEditItem Value="Yes, always" Selected="true" />
        <dx:ListEditItem Value="No, never" />
    </Items>
</dx:ASPxRadioButtonList>

Run Time

csharp
using DevExpress.Web;
...
protected void Page_Load(object sender, EventArgs e)
{
    ASPxRadioButtonList radioButtonList = new ASPxRadioButtonList();
    radioButtonList.ID = "radioButtonList";
    Page.Form.Controls.Add(radioButtonList);

    radioButtonList.Items.AddRange(new List<ListEditItem>() {
        new ListEditItem { Value = "Yes, this time only" },
        new ListEditItem { Value = "No, not this time" },
        new ListEditItem { Value = "Yes, always", Selected = true},
        new ListEditItem { Value = "No, never" }
    });
}
vb
Imports DevExpress.Web

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim radioButtonList As ASPxRadioButtonList = New ASPxRadioButtonList()
    radioButtonList.ID = "radioButtonList"
    Page.Form.Controls.Add(radioButtonList)

    radioButtonList.Items.AddRange(New List(Of ListEditItem)() From {
        New ListEditItem With {
            .Value = "Yes, this time only"
        },
        New ListEditItem With {
            .Value = "No, not this time"
        },
        New ListEditItem With {
            .Value = "Yes, always",
            .Selected = True
        },
        New ListEditItem With {
            .Value = "No, never"
        }
    })
End Sub

Note

DevExpress controls require that you register special modules, handlers, and options in the Web.config file. You can change this file or switch to the Design tab in the Microsoft Visual Studio IDE to automatically update the Web.config file. Note that this information is automatically registered if you use the DevExpress Template Gallery to create a project.

In order to bind the ASPxRadioButtonList to a data source, use the DataSourceID (DataSource) property. When retrieving items from the data source, items characterisitics, such as the text, value and image, are obtained from specific data fields defined via the ASPxListEdit.TextField, ASPxListEdit.ValueField and ASPxListEdit.ImageUrlField properties.

The layout and rendering settings of items within the list can be defined by using the ASPxCheckListBase.RepeatColumns, ASPxCheckListBase.RepeatDirection and ASPxCheckListBase.RepeatLayout properties.

The common alignment of the text label relative to the radio button within items is specified by the ASPxCheckBox.TextAlign property. The ASPxCheckListBase.ItemImage property allows the common image settings to be applied to all list items.

Note

The client-side equivalent of this editor control is represented by the ASPxClientRadioButtonList object. The editor’s client-side API is enabled if the ASPxEditBase.EnableClientSideAPI property is set to true, or any client event is handled. Available client events can be accessed via the ASPxCheckListBase.ClientSideEvents property.

Implements

Show 15 items

IComponent

IDisposable

IParserAccessor

IDataBindingsAccessor

IControlBuilderAccessor

IControlDesignerAccessor

IExpressionsAccessor

IAttributeAccessor

IUrlResolutionService

INamingContainer

IPostBackDataHandler

IPostBackEventHandler

ICallbackEventHandler

IPropertiesOwner

IDataSourceViewSchemaAccessor

Inheritance

Show 14 items

Object Control WebControl ASPxWebControlBase ASPxWebControl ASPxDataWebControlBase ASPxDataWebControl ASPxEditBase ASPxEdit ASPxListEdit ASPxCheckListBase ASPxRadioButtonList BootstrapRadioButtonList

MVCxRadioButtonList

See Also

ASPxRadioButtonList Members

RadioButtonListProperties

Radio Button List

ASPxClientRadioButtonList

DevExpress.Web Namespace