Typically, a merge block is used to repeat content such as table rows or paragraphs. Another purpose of a merge block is to control the rendering of a complete sub-block such as a table row. Those sub-blocks can be rendered conditionally based on value comparisons of the parent data table.

Consider the following JSON data that is merged into the template that is shown further below:

Loading...

The following screenshot shows the template with 2 nested merge blocks that are highlighted in blue and purple.

Merge Block Template

The blue merge block shall be rendered in case the available value equals false. Otherwise the complete merge block should be removed.

Based on the above JSON data, the following result should be rendered:

Merge Block Template

The outofstock merge block is rendered for the first 2 rows and not rendered for the last row.

To show how to add the conditions programmatically, the template contains both merge blocks without the condition. The following code shows how to add the condition to the merge block outofstock:

Loading...

The MergeBlockInfo TX Text Control .NET Server for ASP.NET
DocumentServer.DataSources Namespace
MergeBlockInfo Class
The MergeBlockInfo class is used to insert a table or paragraph based repeating merge block into a TextControl instance using the DataSourceManager.InsertMergeBlock method.
class can be initialized with any merge block SubTextPart TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
SubTextPart Class
A SubTextPart object represents a user-defined part of a TX Text Control document.
that is part of the template. Each merge block SubTextPart has the prefix txmb_, so that the outofstock merge block has the name txmb_outofstock. Using the BlockMergingCondition TX Text Control .NET Server for ASP.NET
DocumentServer.DataSources Namespace
MergeBlockInfo Class
BlockMergingCondition Property
Gets or sets a condition the parent data row of this merge block has to satisfy so that this merge block is merged at all.
property, a new FilterInstruction TX Text Control .NET Server for ASP.NET
DocumentServer.DataShaping Namespace
FilterInstruction Class
The FilterInstruction class is used to filter merge block data by certain conditions before merging.
is added.

Finally, the settings are applied and stored in the SubTextPart.

These conditions are persistently stored when the template is saved and are used automatically by the MailMerge TX Text Control .NET Server for ASP.NET
DocumentServer Namespace
MailMerge Class
The MailMerge class is a .NET component that can be used to effortlessly merge template documents with database content in .NET projects, such as ASP.NET web applications, web services or Windows services.
class when merging the template with the JSON data:

Loading...

Additionally, the merge field leadtime of the conditional block is populated with values from the outofstock table.