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
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