How to bind to sub-property

Hi,

I am using the GridDataBoundGrid. I want to bind certain columns to sub-properties of my business objects.

For example, suppose you have:

public class Address
{
public string Suburb;
}

public class Person
{
public string Name;
public Address Address;
}

I want one column bound to "Name" and one column bound to "Address.Suburb". The first binding works but the second just shows a blank column.

Any help appreciated.

1 Reply

JS Jeba S Syncfusion Team August 16, 2007 01:44 PM UTC

Hi Kasey,

Thank you for posting query to us.

Please refer this sample which shows how to bind the subproperty in GridDataBoundGrid.
http://websamples.syncfusion.com/samples/Grid.Windows/F67349GDBG/main.htm

The column titled "Address Workaround" uses C# code to access the sub-property. If you would like to set MappingName to "Payee.Address" to bind to the Address property of the Payee property of an Entry "row object". Then you will let the CellValue return the "row object", and you can use the DisplayMember to point to a property in this 'row object'. (If you set the GridStyleInfo.ShowButtons property to GridShowButtons.Hide, then you would not know the cell was a combobox.)


gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.ShowButtons = Syncfusion.Windows.Forms.Grid.GridShowButtons.Hide;


Thank you for using Syncfusion Products.

Best Regards,
Jeba.


Loader.
Up arrow icon