GrapeCity ActiveReports (Formerly DataDynamics ActiveReports) DataBinding

February 1st, 2012 by admin Leave a reply »

I have been a long time user of Active Reports for Visual Basic 6 and then in the .net world, I think I have used every version of ActiveReports since they released the first version.  I wanted to write about a little known fact that you may or may not know about this tool that could save you from writing tons of logic to get the data displayed you want.  Lets say you have a couple of simple classes like below:

public class Person{
     public string Name {get;set;}
     public Job Job {get; set;}
}

public class Job {
     public string Status {get; set;}
}

You may already know that just by simply making any field on your report with the DataField of “Name” will automatically bind that property to that field as long as your datasource is set to a collection of Person objects. But did you know that the DataField can work like so:

So as you can see, if your Person object has a Job object in it and there is a string property on there called status, it will display it as long as the property is public. Another caveat to this is if you have a null object in that string, you may not get an error tossed up to your UI, which could make for some fun debugging. Even still, this is a very nice feature that I have long forgotten but recently came across and it was one of those forehead slapping times.

Advertisement

Leave a Reply