Easy Tutorial
❮ Prop Webcontrol Calendarday Date Prop Webcontrol Calendar Shownextprevmonth ❯

ASP.NET ListItem Value Property



Definition and Usage

The Value property is used to set or return the value of the ListItem control.

Syntax

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

It is possible to set the displayed text of the list item using either the Text or Value property along with the inner HTML text.

Examples

Depending on the combination of the Text or Value properties and the inner HTML text, different texts can be displayed with different values. The following table lists all possible combinations and their values:

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 as their default value, there may be empty list items in the list control.


Example

The following example sets the value of a ListItem in a ListBox control:


❮ Prop Webcontrol Calendarday Date Prop Webcontrol Calendar Shownextprevmonth ❯