Search | Contact | Link To Us  

      ASP.NET     

ASP.NET
Dev Environment
Web Forms
Web Controls
ADO .NET
Web User Controls
Deployment
XML Web Services
ASP.NET Feedback Form
Resources
Discussions
VB .NET
About



Advertisement


     HomeASP.NETWeb Controls> DropDownList 

DropDownList 

The DropDownList Web server control is same as the ListBox control but it supports only single selection and displays items in a drop-down manner. The class hierarchy for this control is as follows:

 Object
  Control
   WebControl
    ListControl
     DropDownList

DropDownList Event

The default event of the drop-down list is the SelectedIndexChanged which looks like this in code:

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
'Implementation Omitted
End Sub

Notable property of the drop-down list is the Items property with which we add items to the control. Like ListBoxes this control doesn't support multiple selections.

DropDownList Sample

Drag a DropDownList, Button and a TextBox control on to the form. Add some items to the DropDownList control using it's Item property. The following code will display the item selected from the drop-down list in a textbox when the button is clicked.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
TextBox1.Text = "You Selected:" & DropDownList1.SelectedItem.Text
End Sub

Live Code Demo


   

 


  Privacy Policy | Terms of Use | Site Map | Contact

  © 2004-2010 Startvbdotnet.com. All rights reserved.