Including Table Header In All Document Pages

Hi

I have a simple table with mail merge fields and a datatable with some records.
when use method below to fill the document


Document doc = new Document(@“C:\MailMerge.ExecuteWithRegions.docx”);

DataTable dt = new DataTable(“OrderDetails”);
dt.Columns.Add(“ProductID”);
dt.Columns.Add(“ProductName”);
dt.Columns.Add(“Quantity”);
dt.Columns.Add(“UnitPrice”);
dt.Columns.Add(“Discount”);
dt.Columns.Add(“ExtendedPrice”);

//Repeat these lines to have enough records to fit in two pages in final result document
dt.Rows.Add(1, “Pitza”, 2, 100, 5, 0);
dt.Rows.Add(1, “Pitza”, 2, 100, 5, 0);
dt.Rows.Add(1, “Pitza”, 2, 100, 5, 0);
dt.Rows.Add(1, “Pitza”, 2, 100, 5, 0);
dt.Rows.Add(1, “Pitza”, 2, 100, 5, 0);
dt.Rows.Add(1, “Pitza”, 2, 100, 5, 0);
dt.Rows.Add(1, “Pitza”, 2, 100, 5, 0);
.
.
.


doc.MailMerge.ExecuteWithRegions(dt); //dt is my data table

the result document has two pages but just the first page has Table Headers,
and records which are in the second page has no Table Header.
Can anyone tell me how to change document template/my c# app to have table headers in all pages of result document ?


Hi Amir,

Thanks for your inquiry.

To achieve what you are looking for you just need to add the property "Repeat as header row at the top of each page" under Table Properties to the first row. I have done this for you and attached the modified template.

If you have any troubles please feel free to ask.

Thanks,

Thanks for your solution, it worked for me