Does RadDropDownList support List of Interface as its Data Source?
I have a problem when using one, error is thrown when setting the display member of the drop down list.
I have an Interface, let's say
and this is used in 2 classes
Now when I try to populate a drop down list using these classes, I get the error of
Property accessor 'Name' on object 'TestWinForm.Second' threw the following exception:'Object does not match target type.'
I tried to populate this by
Any idea why ?
I have a problem when using one, error is thrown when setting the display member of the drop down list.
I have an Interface, let's say
public interface IBase
{ string Name { get; set; }}
and this is used in 2 classes
public class First : IBase{ public string Name { get; set; }}
public class Second : IBase
{
public string Name { get; set; }
}Now when I try to populate a drop down list using these classes, I get the error of
Property accessor 'Name' on object 'TestWinForm.Second' threw the following exception:'Object does not match target type.'
I tried to populate this by
private void button5_Click(object sender, EventArgs e) { IList<First> tests = new List<First>(); First test = new First(); test.Name = "Test1"; tests.Add(test); First test2 = new First(); test2.Name = "Test2"; tests.Add(test2); IList<Second> tests2 = new List<Second>(); Second test22 = new Second(); test22.Name = "Test12"; tests2.Add(test22); Second test222 = new Second(); test222.Name = "Test22"; tests2.Add(test222); IList<IBase> all = new List<IBase>(); foreach(var item in tests) { all.Add(item); } foreach(var item in tests2) { all.Add(item); } radDropDownList1.DataSource = all; radDropDownList1.DisplayMember = "Name"; }Any idea why ?