Map Object from an Object

Hello, 

I just wondering if there is anyway I can achieve this in the most simple way:

I have two class:

      public class BillingRate
     {
             public int BillPeriod { get; set; }
             public int ConsumerTypeId { get; set; }
             public ConsumerType ConsumerType { get; set; } // a ConsumerType class
             public decimal Rate { get; set; }

     }

    public  class ConsumerType 
    {
           public int Id { get; set; }
           public string Code { get; set; }
           public string Description { get; set; }
     }

Here's the thing, I already display the BillPeriod and Rates on the SfDatagrid by simply declaring the name of the attribute itself on SfDatagrid>Columns>MappingName. The problem is, is there anyway to display also the ConsumerType.Description on the SfDatagrid column list since it was also a part of BillingRates class?





3 Replies

NK Neelakandan Kannan Syncfusion Team March 2, 2020 06:00 PM UTC

Hi Erano,

Thanks for using Syncfusion products.

You can specify the column for complex property by mentioning the column's MappingName as  "ConsumerType.Description". For more information, please refer the below UG link,
https://help.syncfusion.com/windowsforms/datagrid/databinding#binding-complex-properties

Thanks,
Neelakandan





ER Erano March 2, 2020 07:07 PM UTC

Thank you so much for fast reply. Solved.


PR Padmini Ramamurthy Syncfusion Team March 4, 2020 07:13 AM UTC

Hi Erano, 
  
You are most welcome:) and also we are glad to know that the issue has been resolved. 
  
Regards, 
Padmini  


Loader.
Up arrow icon