Easy Tutorial
❮ Prop Webcontrol Calendar Todaydaystyle Control Radiobutton ❯

ASP.NET ListItem Text Property



Definition and Usage

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

Syntax

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

It is possible to set the displayed text of a list item using either the Text or Value property, as well as the inner HTML text.

Examples

Different combinations of the Text or Value property and inner HTML text can display different texts and use different values. The following table lists all possible combinations and their results:

Inner HTML Text Property Value Property Displayed Text Used Value
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: Since both the Text and Value properties have an empty string default value, there may be empty list items in the list control.


Example

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


❮ Prop Webcontrol Calendar Todaydaystyle Control Radiobutton ❯