Export (0) Print
Expand All

ListItem.Selected Property

Gets or sets a value indicating whether the item is selected.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

member Selected : bool with get, set

Property Value

Type: System.Boolean
true if the item is selected; otherwise, false. The default is false.

Use the Selected property to determine whether the ListItem is currently selected in the list control that contains it. This property is commonly used, when iterating through a collection of ListItem objects in a list control, to determine whether an item is selected.

TopicLocation
How to: Set the Selection in List Web Server ControlsBuilding ASP .NET Web Applications
How to: Set the Selection in List Web Server ControlsBuilding ASP .NET Web Applications
How to: Set the Selection in List Web Server Controls (Visual Studio)Building ASP .NET Web Applications in Visual Studio

The following example demonstrates how to use the Selected property when iterating through the Items collection of a CheckBoxList control to determine which check boxes are selected.

NoteNote

The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Forms Page Code Model.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
Show:
© 2015 Microsoft