I´m trying to get the value of from all ListItems in a DropDown list, but when I treat them as a Control, I get an error:
cannot convert type 'system.web.ui.control' to 'system.web.ui.webcontrols.listitem'
My code:
if (c.GetType() == typeof(ListItem))
string id = c.ID;
string value = ((ListItem)(c)).Value; ///I get the error here (ListItem)(c)
How can I get those values? I would like to do it without knowing the ID from those elements.
Can you try this?