Cannot bind a DataObjectView with sub-DataObjectList

Nov 2, 2010 at 3:08 PM
Edited Nov 2, 2010 at 3:22 PM

Hi Jörg,

I have this piece of code:

DataObjectList<Item> list = new DataObjectList<Item>();
DataObjectView<Item> view = list.DefaultView;
ultraGrid1.DataSource = view;

and my Data Objects look like this: 

public class Item : DataObject
{
    [DisplayName("My Number")]
    [DataMember]
    public int Number { get; set; }

    [DisplayName("My Text")]
    [DataMember]
    public string Text { get; set; }

    [DisplayName("My Date")]
    [DataMember]
    public DateTime? Date { get; set; }

    private DataObjectList<SubItem> _subItems = new DataObjectList<SubItem>();
    [DisplayName("My SubItems")]
    [DataMember]
    public DataObjectList<SubItem> SubItems
    {
        get { return _subItems; }
        set { _subItems= value; }
    }
}

public class SubItem : DataObject
{
    public string MyProperty { get; set; }
}

 

As you can see, my Item has a DataObjectList of SubItems.

If I bind my empty DataObjectList of Items to a Grid, I get the following Exception:

TargetInvocationException: Property accessor 'SubItems' on object 'Mynamespace.SubItem' threw the following exception:'Object does not match target type.'
   on System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component)
   on Thinktecture.DataObjectModel.DataPropertyDescriptor.GetValue(Object component) in C:\Apps\DataObjectModel\DataObjectView\DataPropertyDescriptor.cs:Line 79.
   on System.Windows.Forms.RelatedCurrencyManager.ParentManager_CurrentItemChanged(Object sender, EventArgs e)
   on System.Windows.Forms.CurrencyManager.OnCurrentChanged(EventArgs e)

I am using version 0.13

 

Best Regards from Germany

Marc

Nov 10, 2010 at 4:24 PM

Hi again,

this problem only occurs with Infragistics's UltraGrid, and if I set maximum of band level to "1", it works.

It seems that there need to be done more for this feature, but I don't need it now. So everything is fine :-)

 

Regards

Marc