Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP.NET ListItem Text Property

ASP.NET ListItem Text Property


ListItem Control ListItem control


Definition and Usage

The Text property is used to set or return the text of the ListItem control.

Syntax

/>

property Description
string A string value that specifies the text of the ListItem control.

The text of the displayed list item may be set using the Text or Value property and the inner HTML text.

Example

Text3

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:

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

**Note:** Because both the Text and Value properties have an empty-string default value, list controls may contain empty list items.


Example

The following example sets the ListItem text in a ListBox control:

Demo Example »


ListItem Control ListItem control