get the selected item of a DropDownList

  • Thread starter Thread starter Eranga
  • Start date Start date
E

Eranga

I want to get the selected item of a DropDownList. Is
DropDownList1.SelectedIndex the only way of doing this. It seems
ineficient to get a number and later compare it and get the string.
Please some one help me.
Thanks in advance.
 
Hi Eranga,

Basically, SelectedIndex property is the only way to get the selected item of a DropDownList.
However, instead of retrieving the index first and then getting the string, you can straight away get
the value by using the following code:

Me.ddlLocation.Items(Me.ddlLocation.SelectedIndex).Value

HTH

Mona[Grapecity]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top