I've run into a very strange issue with binding a simple List of objects to a DropDownList. Given the following code:
this.myDDL.DataSource = null; //in here to make sure any pre-existing source isn't the problemList<Person> lst = new List<Person>(); var qry = Employees.List(load); //Returns List<Person> with no errors every timelst.AddRange(qry.ToArray()); //Proof that there are no errors. lst.AddRange() works flawlessly on the datathis.myDDL.BindingContext = new BindingContext(); //just added this, in case it was the issuethis.myDDL.DataSource = lst; //bombs.
The very strange thing is that the error thrown is an Oracle error. Normally, I'd be pestering Oracle about it, but the weird bit is that it only throws the error when assigning the datasource. This doesn't match Oracle error ORA:00933 (SQL Command not properly ended) at all, but that's the error that is thrown. The unnecessary extra code above is entirely a result of me trying to isolate a cause, but the query itself that runs to fill in one of these objects is a Stored Procedure that is called in our Production environment many times a day in the exact same way. The object itself is too simple to be the cause:
public class Person{ public int ID {get;set;} public string FullName {get;set;} public override string ToString() { return ID.ToString() + "(" + FullName + ")"; }}There are no null values in any property of the objects, no nulls added to the list, and the error doesn't occur until Binding. Does the Telerik RadDropDownList recall the constructor of each object when using a List<T> as a DataSource? If not, why would the error appear when binding instead of when the objects are initially constructed?
