davecapone
Programmer
Hi,
I am using the following C# code to populate a DropDownList Box named Category.
foreach (DataRow row in ds.Tables[0].Rows) {
ListItem currentItem=new ListItem();
currentItem.Text=row[0].ToString();
currentItem.Value=row[1].ToString();
CategoryList.Add(currentItem);
}
Category.DataSource=CategoryList;
DataBind();
Problem is for whatever reason, when it is binded to the DataSource, the Text and Value properties in the HTML are the same. I know the data in the DataTable is properly because if I switch the 0 and 1 in the row subscript, the data properly changes. But for whatever reason, whatever is set for the Text field also becomes the value field.
Any suggestions?
I am using the following C# code to populate a DropDownList Box named Category.
foreach (DataRow row in ds.Tables[0].Rows) {
ListItem currentItem=new ListItem();
currentItem.Text=row[0].ToString();
currentItem.Value=row[1].ToString();
CategoryList.Add(currentItem);
}
Category.DataSource=CategoryList;
DataBind();
Problem is for whatever reason, when it is binded to the DataSource, the Text and Value properties in the HTML are the same. I know the data in the DataTable is properly because if I switch the 0 and 1 in the row subscript, the data properly changes. But for whatever reason, whatever is set for the Text field also becomes the value field.
Any suggestions?