DropdownList, DataValueField, DataTextField and Custom Collections..

P

Parodi Development

Hi,

I have a Custom Collection (derived from NameValueCollection) that contains
Items of type Person with 3 properties : Name, Surname, DateOfBirth.

I use the following code :

PersonCollection pCol = new PersonCollection();
.... Fill Collection with Person objects..

Then in a WebPage with a DropdownList named dropDown1 I use :

private void page_load()
{
dropDown1.DataSource = pcol;
dropDown1.DataTextValue = "Name";
dropDown1.DataFieldValue = "DateOfBirth"
dropDown1.DataBind();
}

And I still can't get it to work.. Any idea on how to bind a custom
collection to a dropdownList and then specify which property to have
displayed as text in the dropdown and which property to store the value I
need to get back after user selection ???

Thanks in advance.
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top