Skip Navigation LinksASP.Net 2.0 Training : ASP.Net DropDownList
Banner for ASP.Net 2.0 training classes in Visual Basic 2005 

Skip Navigation Links
ASP.Net 2.0 Training
VS File Management
ASP.Net Image
ASP.Net Checkbox
ASP.Net ImageButton
ASP.Net RadioButton
ASP.Net Literal
ASP.Net Panel
ASP.Net LinkButton
ASP.Net Calendar
ASP.Net BulletedList
ASP.Net FileUpload
ASP.Net User Controls
ASP.Net PlaceHolder
ASP.Net Lists
ASP.Net CheckBoxList
ASP.Net DropDownList
ASP.Net Data Access
ASP.Net DetailsView
ASP.Net FormView
ASP.Net Repeater Control
ASP.Net:Master Pages
Sending EMail
MultiView
Tabbed MultiView
ASP.Net:Wizard Control
Login Controls 1
ASP.Net:Site Navigation
ASP.Net:Classes
ASP.Net:SQLDataSource Control
ASP.Net:Error Handling
ASP.Net:dataTables
ASP.Net:datasets

Visit my other site:

Free Flash 8 tutorials and training

Free Dreamweaver Video Tutorials

Free PHP Training




If you like this site please link to it


DropDownList

Property

Description

SelectedIndex

Index of the item selected

  • Open Visual Studio
  • Add a new webform call it DropDownList.aspx
  • Add a dropDownlist and name it ddlState
  • Add a label control and name it lblDisplay
  • Select the smart tag on the dropdownlist
  • Check the enable AutoPostBack
  • Select Edit Items

  • Click Add
  • Change the text to Pick your state
  • Leave the value blank
  • Click Add again
  • Enter Ohio in the text and OH in the value
  • Add three more
    • Florida Fl
    • California CA
    • Kentucky KY

  • Click OK
  • Test it
  • Double-click the page and add this code to the page_load
1 If ispostback then
2    If ddlState.SelectedIndex=0 then
3       lblDisplay.text="You did not select anything"
4    else
5       lblDisplay.text="State: " & ddlState.SelectedItem.text & "<br />"
6       lblDisplay.text+="Abbrev: " & ddlState.SelectedItem.value & "<br />"
7       lblDisplay.text+="SelectedIndex: " & ddlState.SelectedIndex
8    end if
9 end if


      ASP.Net 2.0 tutorials & training