Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
645
How to create Hierarchy out of a FlatDataSource
posted

Hi,

I have a tough time dealing with Infragistics xamPivotGird. I have classes say Customer and Address.

public class Customer

{

  string Name {get; set;}

  Address CustAddress {get; set;}

}

public Address

{

 string Street{get; set;}

 string State {get; set;}

 string City {get; set;}

 string ZipCode {get; set;}

}

In some cases, when my Address is null. while creating Hierarchy, using the below code, I don't see the Hierarchy being built or show up when expanded

 var hierarchy = new HierarchyDescriptor<Customer>(p => p.CustAddress );

 hierarchy.AddLevel(p => "All Addresses", "All Addresses");

 hierarchy.AddLevel(p => p.CustAddress.ZipCode?? "", "ZipCode");

Please guide me here.....Its kind of urgent.

Parents
No Data
Reply
  • 34510
    Verified Answer
    Offline posted

    Hi Rajib,

    The expression is evaluated when you expand the "All Addresses" hierarchy.  If the address is null then that code is going to fail with a NullReferenceException.  You should see the NullReferenceException in your Visual Studio output window.  Please change your expression to handle the null value.  Something like this perhaps:

    hierarchy.AddLevel(p => (p.CustAddress == null) ? "" : p.CustAddress.ZipCode, "ZipCode");

Children