List Controls in ASP.NET: Part 1


The List controls enable us to display simple lists of options. For example, we can use the RadioButtonList control to display a group of radio buttons, or the BulletedList control to display a list of links. In this series of article we will also discuss on DropDownList, RadioButtonList, ListBox, CheckBoxList, and BulletedList controls too. We will also discuss how to bind them to a data source such as a database tables. 

Declaring List Items

The List controls render a list of options. Each option is represented by an instance of the ListItem class. For example, we can use the page in given below to render a set of options for selecting our subject and degree.


<%@ Page Language="VB" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""">

<script runat="server">


<html xmlns="" >
<head id="Head1" runat="server">
    <title>Favorite Movie</title
    <form id="form1" runat="server">

        Text="Chose one of the Subject:"

            Value="subject2" />
            Value="subject3" />
            text="Expression Blend"
            Value="subject4" />
    <hr />
    <br />
        Text="Chose one of the Degree:"
    <br />
            Value="degree1" />
            Value="degree2" />
            Value="degree3" />
            Value="degree4" />


In above coding we have used a RadioButtonList control twice. This control contains four ListItem controls separately in twice of RadioButtonList.

The ListItem control supports the following five properties:

  • Attributes: it enables us to add HTML attributes to a list item.
  • Enabled: it enables us to disable a list item.
  • Selected: it enables us to mark a list item as selected.
  • Text: it enables us to specify the text displayed by the List Item.
  • Value: it enables us to specify a hidden value associated with the List Item.

Note: Continue in Next Part.


Up Next
    Ebook Download
    View all
    View all