I am trying to populate a two-column dropdown list from a populated
datareader (dr) having two fields from the Categories table of the
Northwind database: CategoryID and CategoryName.
I've used this type of construction successfully with VB.NET (from
which I am now transistioning...) and it has worked unfailingly with my
dropdowns there.
However, when I do this in C#, the result is only the CateogryID
displaying in the dropdown. And yet, and yet...in the Command Window of
the IDE, I can query the contents of the ListItem and expose its
current values, for example "li.Value = 1" and "li.Text = Beverages."
Code Snip:
while (dr.Read())
{
ListItem li = new ListItem(dr.GetValue(0).ToString(),
dr.GetValue(1).ToString());
ddlCategory.Items.Add(li);
}
//dr.GetValue(0) is the CategoryID and dr.GetValue(1) is the
CategoryName
Thank you very much -
Jules
|