December 2001
Intermediate to advanced
416 pages
8h 16m
English
The DropDownList control allows the user to select one of any number of items. In our case we wish to present the user with the available appointment times. Unlike a list box, a drop-down list displays only one item—the item currently selected. To see the entire item list, the user clicks on the right-hand down arrow. We can either add each item individually to the list:
DropDownList1.Items.Add( "7:00 AM" );
or else assign a collection of items to the control's DataSource property—for example,
private void Page_Load( object sender, System.EventArgs e ) { if ( ! IsPostBack ) { string [] times = { "7:00 AM", "8:00 AM", "9:00 AM", "10:00 AM", "11:00 AM", "12:00 Noon", "2:00 PM", "3:00 PM", "4:00PM" }; DropDownList1.DataSource ...Read now
Unlock full access