ASP.NET ListItem controls
Definition and Usage
ListItem control creates an item in the list.
This control controls used in conjunction with the following list: <ASP: the ListBox> , <ASP: the RadioButtonList> and <ASP: a BulletedList> .
grammar
Enabled="True|False"
Selected="True|False"
Text="label"
Value="value" />
Attributes
属性 | 描述 | .NET |
---|---|---|
Attributes | 可选的。此类不直接支持的 ListItem 的属性名和值对的集合。 | 1.0 |
Enabled | 可选的。规定是否禁用或启用项目。 | 2.0 |
Selected | 可选的。规定是否选定该项。 | 1.0 |
Text | 可选的。在 ListItem 中显示的文本。 | 1.0 |
Value | 可选的。ListItem 的值。 | 1.0 |
Web Control Standard Properties
For a full description, visit the Web Control Standard Attributes .
Control Standard Properties
For a full description, go to Control Standard Attributes .
It is possible to use the Text or Value properties and the inner HTML text to set the text list entries.
Examples
According to Text or Value properties and the combination of inner HTML text to display different text, and use a different value. The following table lists all the possible combinations and their results:
Inner HTML | Text 属性 | Value 属性 | 显示的文本 | 使用的值 |
---|---|---|---|---|
已设置 | 已设置 | 已设置 | Inner HTML | Value 属性 |
已设置 | 已设置 | 未设置 | Inner HTML | Inner HTML |
已设置 | 未设置 | 已设置 | Inner HTML | Value 属性 |
已设置 | 未设置 | 未设置 | Inner HTML | Inner HTML |
未设置 | 已设置 | 已设置 | Text 属性 | Value 属性 |
未设置 | 已设置 | 未设置 | Text 属性 | Text 属性 |
未设置 | 未设置 | 已设置 | Value 属性 | Value 属性 |
未设置 | 未设置 | 未设置 | 未设置 | 未设置 |
Tips and Notes
Note: Due to Text and Value property has an empty string default values, so the list of controls may empty list item.
Examples
BulletedList with the basic ListItem
This example shows the .aspx file BulletedList control with two ListItem's.
ListItem with different attributes of the ListBox
This example shows the .aspx file ListBox control with several of ListItem. Items in the list using different ListItem property to display text.
With disabled ListItem of ListBox
This example shows a ListBox control with the ListItem disabled.
RadioButtonList with the selected ListItem's
This example shows a RadioButtonList control with the selected ListItem.
Web server control