By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,727 Members | 768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,727 IT Pros & Developers. It's quick & easy.

Problem with binding DropDownList with ListItemCollection

P: n/a

There is a ListItemCollection containing ListItems (of course), each of whose Value and Text properties have been set. The Value and Text's values are different

ListItem[0].Text = "Name0"
ListItem[0].Value = "ID0"

ListItem[1].Text = "Name1"
ListItem[1].Value = "ID1"

The above ListItem(s) are a part of the ListItemCollection that I mentioned before

Then I set the DataSource of a DropDownList (on my page) to the ListItemCollection and bind it

DropDownList.DataSource = ListItemCollection

But the DropDownList does not pick up the Value and the Text properties separately. It sets the Text Property of each ListItem as the Value also

On the other hand if I iterate through the ListItemCollection and Add() each ListItem to the DropDownList, then the Value and Text fields are picked separately


foreach(ListItem in ListItemCollection

Can someone tell me why this is happening and if this is some sort of known issue in .NET

Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.