problem with ListItem databinding

D

DAXU

Hi,

I got some old code from a leaving colleague and it is like this:

List<ListItem> subProductGroupList = new List<ListItem>();
for (int i= 0; subProductCount < classA.Length; i++)
{
ListItem subProductListItem = new ListItem();
subProductListItem.Text = classA.ProductValue;
subProductListItem.Value =
classA.ProductSubGroupKey;
subProductGroupList .Add(subProductListItem);
}
this.ProductSubGroupDropDownList.DataSource = subProductGroupList ;
this.ProductSubGroupDropDownList.DataBind();


The problem is that after databinding, the dropdownlist's items did
not get the Value. For example, if In the loop one ListItem's text is
"This is Text" and value is "This is value", after data binding, that
item's text and value both are "This is Text".

Acutally, if I just clear the items for the dropdownlist and just add
the ListItem directly to the dropdownlist, the value and text are
correct. So there must be something happened in the databinding
process.
Can someone fingure out why it was not working?

Cheers,
Jerry
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top