Posted 7 August 2023, 11:28 pm EST
Hello,
I have just been experimenting with Section Reports and Object DataSources. In doing so, I found that I can do this without Fields collection and FetchData. Since I can’t find anything to this effect in the help, I’m wondering if my code is ok and will work reliably.
I have a class, e.g. “Customer”
with a property “CompanyName”
and a property “Persons” which is a List,
where the class Person has the properties “FirstName” and “LastName”.
A section report should show
the company name in the report header and
the persons in the detail section.
I pass an instance of customer in the constructor of the report and have the following code in DataInitialize:
//company data (txtCompanyName is in report header):
txtCompanyName.Value = customer.CompanyName;
//Person data (txtPerson* are in details section):
this.DataSource = customer.People;
txtPersonFirstName.DataField = nameof(Person.FirstName)
txtPersonLastName.DataField = nameof(Person.LastName)
This works perfectly and shows the expected data, without using the Fields collecion oder writing code in FetchData.
Is this Ok?
Thanks,
Usch Wildt