ASP.NET ListItem Control
Web Server Controls
Definition and Usage
The ListItem control creates an item in a list.
This control is used with the following list controls:asp:ListBox、 asp:RadioButtonList and asp:BulletedList。
Syntax
Enabled="True|False" Selected="True|False" Text="label" Value="value" /> AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled, SkinID, Style, TabIndex, ToolTip, Width For a complete description, please visit Web Control Standard Properties。 AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls, EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site, TemplateControl, TemplateSourceDirectory, UniqueID, Visible For a complete description, please visit Web Control Standard Properties。 The text of the displayed list item may be set using the Text or Value property and the inner HTML text. Depending on the combination of the Text or Value property and the inner HTML text, different text can be displayed and different values used. The table below lists all possible combinations and their results: **Note:** Because both the Text and Value properties have an empty-string default value, list controls may contain empty list items. BulletedList with basic ListItem
ListBox with ListItem of different attributes
ListBox with disabled ListItem
RadioButtonList with selected ListItem
property
property
Description
.NET
Attributes
Optional. A collection of ListItem property names and value pairs not directly supported by this class.
1.0
Enabled
Optional. Specifies whether the item is disabled or enabled.
2.0
Selected
Optional. Specifies whether the item is selected.
1.0
Text
Optional. The text displayed in the ListItem.
1.0
Value
Optional. The value of the ListItem.
1.0
Web Control Standard Properties
Web Control Standard Properties
Example
Inner HTML
Text property
Value property
Displayed text
Value used
Set
Set
Set
Inner HTML
Value property
Set
Set
Not set
Inner HTML
Inner HTML
Set
Not set
Set
Inner HTML
Value property
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
Example
This example shows a BulletedList control with two ListItem elements in the .aspx file.
This example shows a ListBox control with several ListItem elements in the .aspx file. The items in the list use different attributes to display the ListItem text.
This example shows a ListBox control with a disabled ListItem.
This example shows a RadioButtonList control with a selected ListItem.
Web Server Controls