Declaring List Items : ListItem « ASP.net Controls « ASP.NET Tutorial






The ListItem control supports the following five properties:

Attributes: attributes of a list item.

Enabled:    disable or enable a list item.

Selected:   mark as selected.

Text:       text displayed by the list item.

Value:      specify a hidden value associated with the list item.



<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Favorite Product</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <asp:Label
        id="lblProducts"
        Text="Favorite Product:"
        AssociatedControlID="rblProducts"
        Runat="server" />

    <asp:RadioButtonList
        id="rblProducts"
        Runat="server">
        <asp:ListItem
            Text="The Remains of the Day"
            Value="product1" />
        <asp:ListItem
            Text="Star Wars"
            Value="product2" />
        <asp:ListItem
            Text="Pulp Fiction"
            Value="product3" />
    </asp:RadioButtonList>

    </div>
    </form>
</body>
</html>








3.17.ListItem
3.17.1.A simple BulletedList control
3.17.2.Add asp:ListItem to asp:DropDownList
3.17.3.Declaring List Items
3.17.4.Using the LinkButton value for the DisplayMode attribute (C#)
3.17.5.Using the LinkButton value for the DisplayMode attribute (VB)
3.17.6.All items and selected item in a selectable control
3.17.7.Disabling certain ListItems from a collection (C#)
3.17.8.Disabling certain ListItems from a collection (VB)
3.17.9.Change style for ListItem
3.17.10.Set style for label