Problem with binding DropDownList with ListItemCollection

Discussion in 'ASP .Net' started by =?Utf-8?B?UkFNQURV?=, May 16, 2004.

  1. Hi

    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

    i.e.
    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
    DropDownList.DataBind()

    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

    i.e.

    foreach(ListItem in ListItemCollection

    DropDownLIst.Items.Add(ListItem)


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

    RAMADU
    =?Utf-8?B?UkFNQURV?=, May 16, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kurt Mang
    Replies:
    3
    Views:
    3,946
    szabelin
    Aug 18, 2003
  2. =?Utf-8?B?UkFNQURV?=
    Replies:
    2
    Views:
    8,298
    Ashish M Bhonkiya
    May 16, 2004
  3. =?Utf-8?B?YmVub2l0?=

    ListItemCollection Sort Alphabetical

    =?Utf-8?B?YmVub2l0?=, Nov 3, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    11,237
    =?Utf-8?B?U3JlZWppdGggUmFt?=
    Nov 3, 2005
  4. Brano
    Replies:
    3
    Views:
    758
    Kevin Spencer
    Nov 8, 2005
  5. =?Utf-8?B?UmljaGFyZEg=?=

    DataBinding ListItemCollection to DropDownList

    =?Utf-8?B?UmljaGFyZEg=?=, Apr 12, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    4,305
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Apr 12, 2006
Loading...

Share This Page