Can't get the text from a Dropdownlist

B

Barry

Hi,

I have dropdownlist that I'm trying to bind to an arraylist. The items
in the array get populated correctly, but I can't seem to detect the
SelectedItem.Text property when selecting an item. This property returns
an empty string. Here's the code:

Dim myMaterials As System.Collections.ArrayList =
MyNamespace.DrillDownReport.GetMaterialsList()

With dropMaterial
.Items.Clear()
.DataSource = myMaterials
.DataBind()
End With

I've tried adding

dropMaterials.DataTextField="Material"

to get to the property in the object, but it doesn't help. Besides, the
few examples I've seen don't set this property.

I'm stumped!
 
V

vMike

There are two values the DataTextField and the DataValueField.
You get the text with selecteditem.text and the value with
selecteditem.value
the text value is what is displayed and the value is what you want its value
to be. You should bind one column to each.
 

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
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top