469,363 Members | 2,640 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,363 developers. It's quick & easy.

DropdownList, DataValueField, DataTextField and Custom Collections..

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.


Nov 18 '05 #1
0 2636

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by DC Gringo | last post: by
reply views Thread by fwirtanen | last post: by
11 posts views Thread by Santosh | last post: by
reply views Thread by andy | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.