ListItem class properties and its descriptions

A ListItem control is an individual data item within a data-bound list control, such as a ListBox or DropDownList control.

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

Property

Description

Supported in .NET version

Attributes

Returns a collection of attribute name and value pairs for the ListItem that are not directly supported by the class.  Web developers can use the Attributes collection to manage pairs of attribute name and value declared in the opening and closing tags of the control, but not directly supported by the class. They can programmatically add or remove attributes to the collection.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

Enabled

This property is used to get or set a value indicating whether the list item is enabled. Its default value is false. Its value is true if the list item is enabled; otherwise, false. A ListItem control that is disabled is dimmed to indicate that it cannot be selected. Web developers can this property to disable a ListItem control in either a RadioButtonList control or a CheckBoxList control, but they cannot use this property to disable a ListItem control in a DropDownList control or ListBox control.

2.0, 3.0, 3.5, 4.0

Selected

This property gets or sets a value indicating whether the item is selected. Its default value is false. Its value is true if the item is selected; otherwise, false. Web developers commonly use this property,  when they are iterating through a collection of ListItem objects in a list control, to determine whether an item is selected.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

Text

The property is used to get or set the text displayed in a list control for the item represented by the ListItem. Its default value is String.Empty.

Note: If the Text property contains a null reference (Nothing in VB.NET), the get accessor returns the value of the Value property. If the Value property, in turn, contains a null reference (Nothing in VB.NET), String.Empty is returned.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

Value

Returns or sets the value associated with the ListItem. Its default value is String.Empty. If the Value property contains a null reference (Nothing in VB.NET), the get accessor returns the value of the Text property. If the Text property, in turn, contains a null reference (Nothing in VB.NET), String. Empty is returned.

1.0,1.1, 2.0, 3.0, 3.5, 4.0