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
Visit my other site:

certification training

Free Flash tutorials and training

Free Dreamweaver Video Tutorials

Free PHP Training

Visual Basic Windows 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