Back to Devexpress

ASPxCheckBoxList.SelectedItems Property

aspnet-devexpress-dot-web-dot-aspxcheckboxlist-ce1572f6.md

latest2.8 KB
Original Source

ASPxCheckBoxList.SelectedItems Property

Gets the collection of selected items within the check box list.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public SelectedItemCollection SelectedItems { get; }
vb
Public ReadOnly Property SelectedItems As SelectedItemCollection

Property Value

TypeDescription
SelectedItemCollection

A SelectedItemCollection object that contains the selected items.

|

Remarks

Use the SelectedItems, SelectedIndices, or SelectedValues properties to get information about selected items in code behind.

aspx
<dx:ASPxCheckBoxList ID="checkBoxList" runat="server">
    <Items>
        <dx:ListEditItem Value="1" />
        <dx:ListEditItem Value="2" />
        <!-- ... -->
    </Items>
</dx:ASPxCheckBoxList>
<dx:ASPxButton runat="server" ID="ClickButton" Text="Click" OnClick="ClickButton_Click" />
csharp
protected void ClickButton_Click(object sender, EventArgs e)
{
    var selectedValues = checkBoxList.SelectedValues;
    var selectedItems = checkBoxList.SelectedItems;
    var selectedIndices = checkBoxList.SelectedIndices;
    // ...
}
vb
Protected Sub ClickButton_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim selectedValues = checkBoxList.SelectedValues
    Dim selectedItems = checkBoxList.SelectedItems
    Dim selectedIndices = checkBoxList.SelectedIndices
End Sub

If the SelectedItems property returns null, make sure that you set the ValueType property to an .NET type that matches the ValueField column type. Otherwise, the editor cannot find the corresponding item because the editor’s ValueType property does not match the item type (String by default).

See Also

Check Box List

ASPxCheckBoxList Class

ASPxCheckBoxList Members

DevExpress.Web Namespace