473,382 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Problem with binding DropDownList with ListItemCollection

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
Nov 18 '05 #1
0 1268

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kamaumalone | last post by:
I have a dropdownlist which lives inside of a repeater. The repeater accepts user input via textboxes and the aforementioned dropdownlist. The repeater accepts phone numbers and allows for an...
6
by: Kurt Mang | last post by:
Hi all -- I hate to yell "BUG", but can anyone explain why I cannot get a dropdown list / checkboxlist to recognise the Value property of a ListItemCollection (created at runtime) that I bind...
0
by: James | last post by:
Hi, I have a ListItemCollection which contains data like below: System.Web.UI.WebControls.ListItemCollection licListItems = new System.Web.UI.WebControls.ListItemCollection ();...
2
by: RAMADU | last post by:
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.Text = "Name0"...
4
by: Raphaël Désalbres | last post by:
Hello, everybody, I'm having a problem creating a control...All I want to do is a simple poll system, so I need to input (trough a ListitemCollection) the values from the user. The problem is...
0
by: Gunjan Garg | last post by:
The issue here is - When the postback event happens the selected index is always returing the first value. Appreciate your help in advance. Thanks Here is the code...
10
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
1
by: RichardH | last post by:
Hi, I have a ListItemCollection that I bind to DropDownList: ListItemCollection items = new ListItemCollection(); ListItem item; item = new ListItem("Option 1", "1"); items.Add(item); item =...
0
by: tasmontique | last post by:
I hope someone can help me. I have an error that I can not seem to figure out. All I need is an unbound dropdownlist to navigate to urls withing the website. I have gotten as far as to populate field...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.