binding datasource to dropdownlist control

  • Thread starter Thread starter DesignerX
  • Start date Start date
D

DesignerX

I am being sent an ArrayList of ListItems.

I can bind to a dropdownlist control using:

oDropDownList.DataSource = oArrayList

This works but when the dropdownlist is rendered both the select box value
and the text are the same (The ListItem.Text), How do I get the
ListItem.Text to render as the text and the ListItem.Value to be the html
select option 'value'?

Thank You,
Stan
 
Use DataTextField and DataValueField properties of dropdownlist to assign
text and value for dropdownlist.
 
Saravana,

Thanks for the reply, unfortunately that is my problem... I do not know how
to use the DataValueField property without looping thru the entire
ArrayList. With an ArrayList of ListItems, how would I use the
DataValueField to refer property to refer to a property of the object within
the array?

Thanks,
Stan
 
Back
Top