We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

collection based on abstract class in DataBoundGrid

I''ve created base class with property Text, then I created collection based on this class. Collection is used in DataBoundGrid. There are some inherited classes from base class that can be added to collection. Everything is working fine if I add elements to collection from zero. But If I use already filled collection with different inherited types there are problems of displaying this collection in DBG. What can I do?

5 Replies

AD Administrator Syncfusion Team February 27, 2004 09:04 AM UTC

Are you saying you can add a series of base objects to your collection, and then set the collection as the DataSource of a GridDataBoundGrid, then it works? But if you add a series of derived objects to your collection, and then set the collection as the datasource, it does not work? Can you provide a sample project showing the problem?


AD Administrator Syncfusion Team February 27, 2004 10:51 AM UTC



AD Administrator Syncfusion Team February 27, 2004 02:26 PM UTC

Thank you for the sample. The grid uses teh first item in teh list to set up properties, and for some reason this is failing when you add your inherited objects. We will have to look into this to see if this si something we can fix. Until we get it fixed, you could just temporarily add a base class object first, and then remove it after you set the datasource. clsBase loB1=new clsBase(); clsInherited1 loI1=new clsInherited1(); clsInherited2 loI2=new clsInherited2(); mCollection=new clsBaseCollection(); mCollection.Add(loB1); mCollection.Add(loI1); mCollection.Add(loI2); dtg.BeginUpdate(); dtg.DataSource=mCollection; mCollection.Remove(loB1); dtg.EndUpdate(); dtg.Refresh();


AD Administrator Syncfusion Team February 27, 2004 03:55 PM UTC

I used the same approach thank you


AD Administrator Syncfusion Team February 28, 2004 08:37 AM UTC

To get this to work without adding the fake entry at the start, you can implement ITypedList in your collectionbase. This requires deriving PropertyDescriptor to implement proper GetValue and SetValue methods for your derived property descriptor. Here is your sample back modified to do this. forumcollection_4383.zip

Loader.
Live Chat Icon For mobile
Up arrow icon