Products Technologies Demo Docs Blog Support Company

Prefixed Merge Field Names: Using Related Tables

Recently, a new Text Control Reporting user asked the following question in our technical support: Can a Word template be merged with a DatSet with multiple tables that have columns with the same name? The answer is: Absolutely yes! Data relations between tables are used automatically by Text Control Reporting. A master table is specified when calling the Merge method. All relations between child tables and the master table is defined as a prefix in the merge field name concatenated with a…

Prefixed Merge Field Names: Using Related Tables

Recently, a new Text Control Reporting user asked the following question in our technical support:

Can a Word template be merged with a DatSet with multiple tables that have columns with the same name?

The answer is: Absolutely yes!

Data relations between tables are used automatically by Text Control Reporting. A master table is specified when calling the Merge method. All relations between child tables and the master table is defined as a prefix in the merge field name concatenated with a dot:

ChildTable[.ChildTable].ColumnName

Our sample database has the following structure:

Prefixed merge field names: Using related tables

The master table is Sales_SalesOrderHeader. The child table Sales_SalesOrderDetail has the child tables Production_Product and Customer_Customer.

A merge field from the master table doesn't need a prefix. AccountNumber is coming directly from the master table Sales_SalesOrderHeader. Merge fields that should be populated with values from related tables are getting a prefix that consists of the relation path concatenated with a dot where the master table is omitted.

The following illustration shows the merge fields on the left side and their relations on the right:

Prefixed merge field names: Using related tables

Notation in Merge Blocks: Access to Nested DataTables

The master table is the base table for the complete report. Inside of merge blocks, the master table for this block is the merge block table. All child tables of this block table can be used inside of the merge block with the same notation. Consider the following merge block:

Prefixed merge field names: Using related tables

The block is named Production_Product. All columns of this base table are used without any prefix. Columns of nested tables can be accessed with the prefix such as Production_ProductProductPhoto.ProductPhotoID which is a related child table of Production_Product.

This concept allows you to iterate over any data, in any way, across any part of the template with different DataTables in various merge blocks.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Reporting

The Text Control Reporting Framework combines powerful reporting features with an easy-to-use, MS Word compatible word processor. Users can create documents and templates using ordinary Microsoft Word skills. The Reporting Framework is included in all .NET based TX Text Control products including ASP.NET, Windows Forms and WPF.

See Reporting products

Related Posts

ASP.NETReportingPDF

.NET C# PDF Generation Techniques: Which Method is Right for Your Project?

This article explains the distinct advantage TX Text Control offers with its true WYSIWYG (What You See Is What You Get) template system, where templates are designed visually, similar to…


ASP.NETReportingASP.NET Core

Best Practices for Mail Merge and Form Field Processing in ASP.NET Core C#…

This article provides best practices for mail merge and form field processing in ASP.NET Core C# applications using TX Text Control .NET Server. It shows how to use the Document Editor to create…


ASP.NETReportingASP.NET Core

Advantages of Flow Type Layout Reporting vs. Banded Reporting or PDF…

This article shows the advantages of flow type layout reporting compared to banded reporting or populating PDF placeholders in .NET C#. It explains the differences and the benefits of using a flow…


ActiveXASP.NETReporting

TX Text Control 32.0 Has Been Released

We are pleased to announce the immediate availability of TX Text Control 32.0 for all platforms including ASP.NET, Windows Forms, WPF and ActiveX.


AngularJavaScriptReporting

Getting Started: Angular Document Editor Attributes Explained

This article explains the possible attributes that can be used when initializing the TX Text Control Document Editor for Angular.