A valuable advantage of the Text Control Reporting Framework is the flexibility through programmability. Developers can use the power of the TX Text Control API during the merge process. While merge fields are populated, an event is fired for each merge field, data row or block row. This gives you the flexibility to manipulate the merge process, to inject formatted text or to remove unnecessary elements.

In this sample, NEXT fields are used to realize alternate row colors. The advantage of this concept is that you can have not only 2 rows with different styles, but unlimited number of table rows with a different background color for instance. The following screenshot shows the template with the NEXT field at the end of the first row of the block (light gray row):

Reporting: Removing empty table rows

The two table rows have the same merge fields. During the merge process, the NEXT field increases the current data row by 1 which results in alternating row colors:

Reporting: Removing empty table rows

As you can see in the above screenshot, this concept might insert an empty row at the end of the table in case the row count is uneven.

Thanks to the flexibility, this row can be removed in the BlockRowMerged event:

private void mailMerge1_BlockRowMerged(object sender,
    TXTextControl.DocumentServer.MailMerge.BlockRowMergedEventArgs e)
{
    byte[] data;

    // create a temporary ServerTextControl to access API
    using (ServerTextControl tx = new ServerTextControl())
    {
        tx.Create();
        tx.Load(e.MergedBlockRow, BinaryStreamType.InternalUnicodeFormat);

        if (tx.Tables.GetItem() == null)
            return;

        Table table = tx.Tables.GetItem();

        // loop through row and remove empty rows
        foreach (TableRow row in table.Rows)
        {
            row.Select();
            if (tx.Selection.Length == table.Columns.Count)
            {
                tx.Selection.Length = 0;
                table.Rows.Remove();
            }
        }

        tx.Save(out data, BinaryStreamType.InternalUnicodeFormat);
    }

    // return the manipulated merged block
    e.MergedBlockRow = data;
}
Reporting: Removing empty table rows

You can download the Visual Studio 2012 sample project and test this on your own. At least, a trial version of TX Text Control .NET for Windows Forms X11 is required.