Telerik RadGrid Throwing an exception when filling an array of objects by their parent type

I just encountered a casting exception when using Telerik RadGrid.

This happens during the DataBind event if I have an array of objects as a data source

radgrid1.DataSource = new BaseObject[] { new ChildObject1(), new ChildObject2() };

where the ChildObject1 and ChildObject2 classes inherit from the BaseObject class.

0


a source to share


1 answer


Just found the answer.



var objects = new BaseObject[] { new ChildObject1(), new ChildObject2() };

radgrid1.DataSource = new List<BaseObject>(objects);

0


a source







All Articles