To bind a list of objects to a RecordBox or other elements in your .dlex template, you need to ensure that the data structure in your LayoutData object matches the template's structure. In your case, you want to populate data for multiple CashAdvance objects within your template.
Assuming that your .dlex template has a RecordBox that should display the properties of each CashAdvance object, you can structure your LayoutData as follows:
DocumentLayout layout = new DocumentLayout(projectDirectory + "\\report.dlex");
LayoutData layoutData = new LayoutData();
// Add the preparedFor data
layoutData.Add("PreparedFor", "Author");
// Create a list to hold the data for CashAdvances
List<Dictionary<string, string>> cashAdvancesData = new List<Dictionary<string, string>>();
// Iterate through your exampleData and add each CashAdvance's properties to a dictionary
foreach (CashAdvance cashAdvance in exampleData)
{
Dictionary<string, string> cashAdvanceDict = new Dictionary<string, string>
{
{ "BranchName", cashAdvance.BranchName },
{ "BusinessDate", cashAdvance.BusinessDate },
{ "SequenceNum", cashAdvance.SequenceNum },
{ "Amount", cashAdvance.Amount },
{ "TransactionDate", cashAdvance.TransactionDate }
};
cashAdvancesData.Add(cashAdvanceDict);
}
// Add the list of dictionaries to the LayoutData under the name "CashAdvances"
layoutData.Add("CashAdvances", cashAdvancesData);
// Now, layout your document
Document doc = layout.Layout(layoutData);
doc.Draw(projectDirectory + "\\test.pdf");
In this code, we convert each CashAdvance object into a dictionary with keys corresponding to the property names. We then add these dictionaries to a list, which is added to the LayoutData object with the name "CashAdvances." This should align with how your .dlex template is structured to accept a list of dictionaries for rendering RecordBoxes.