Can't get the text from a Dropdownlist

  • Thread starter Thread starter Barry
  • Start date Start date
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!
 
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.
 
Back
Top