Reputation: 2861
I'm trying to add an item to a DropDownList from an Oracle datareader, but I keep getting an error that states the line has some invalid arguments.
Can I simply specify the text and the value? In which case, I want them to be the same value coming from the datareader.
TRef.Items.Add(new ListItem(dr["t_ref"], dr["t_ref"]));
Upvotes: 2
Views: 2173
Reputation: 15881
dr["t_ref"]
returns object.
TRef.Items.Add(new ListItem(dr["t_ref"].ToString(), dr["t_ref"].ToString()));
Upvotes: 0
Reputation: 70786
ListItem can take two strings as parameters, you are passing two objects. Try converting the dr object to a string:
TRef.Items.Add(new ListItem(dr["t_ref"].ToString(), dr["t_ref"].ToString()));
Alternatively to be cleaner:
var t_ref = dr["t_ref"].ToString();
TRef.Items.Add(new ListItem(t_ref, t_ref));
http://msdn.microsoft.com/en-GB/library/system.web.ui.webcontrols.listitem.aspx
Upvotes: 1