ListItem control
ASP.NET ListItem Control
Web server control
Definition and usage
The ListItem control can Create an item in the list.
This control is used together with the following list controls: <asp:ListBox>, <asp:RadioButtonList> and <asp:BulletedList>.
Syntax
Enabled="True|False"
Selected="True|False"
Text=" label"
Value="value" />
Attribute
Description | .NET | |||
---|---|---|---|---|
Optional. A collection of property name and value pairs for ListItems that this class does not directly support. | 1.0 | |||
Optional. Specifies whether to disable or enable the item. | 2.0 | |||
Optional. Specifies whether this item is selected. | 1.0 | |||
Optional. The text displayed in the ListItem. | 1.0 | |||
Optional. The value of the ListItem. | 1.0 |
Inner HTML | Text attribute | Value attribute | Text displayed | Value used |
---|---|---|---|---|
set | set | set | Inner HTML | Value attribute |
Set | Set | Not set | Inner HTML | Inner HTML |
Set | Not set | Set | Inner HTML | Value attribute |
Set | Not set | Not set | Inner HTML | Inner HTML |
Not set | Set | Set | Text property | Value property |
Not set | Set | Not set | Text property | Text property |
Not set | Not set | Set | Value property | Value property |
Not set | Not set | Not set | Not set | Not set |
Tips and Notes
Notes: Since both the Text and Value properties have empty string default values, it is possible to have empty list items in the list control.
Example
BulletedList with basic ListItem
This example shows a BulletedList control with two ListItems in an .aspx file.
ListBox with ListItems with different properties
This example shows a ListBox control with several ListItems in an .aspx file. The items in the list use different properties to display the text of the ListItem.
ListBox with disabled ListItem
This example shows a ListBox control with disabled ListItem.
RadioButtonList with selected ListItem
This example shows a RadioButtonList control with selected ListItem.
Web Server Control