get the selected item of a DropDownList

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.
 
M

Mona

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top