Edit this page
Available for: UI for ASP.NET AJAX | UI for ASP.NET MVC | UI for WPF | UI for WinForms

Merge Field

Merge field is a Field element containing a reference to a data field by its name. When a template document is mail merged with the values from a data source, the data field information replaces the merge field. More information on the mail merge feature is available in the respective article: Mail Merge.

Syntax

The syntax of a merge field is demonstrated in Figure 1.

Figure 1: Merge Field Code SyntaxRad Words Processing Concepts Merge Field 01

Inserting

Inserting a merge field is easily achieved through the RadFlowDocumentEditor's InsertField() method. It accepts code as first argument and result as second argument.

Example 1 demonstrates how you can insert a merge field.

[C#] Example 1: Insert merge field

RadFlowDocumentEditor editor = new RadFlowDocumentEditor(new RadFlowDocument());
editor.InsertField("MERGEFIELD First_Name", "Nancy Davolio");

Switches

Switches are a way for the code fragment to specify formatting for the result of the field. More information is available in the Syntax and Switches section of the Fields article.

The possible switches for a merge field are:

  • \b "text": Specifies text, which shall be inserted before the Merge Field in case the field is not blank.

  • \f "text": Specifies text, which shall be inserted after the Merge Field in case the field is not blank.

Example 2 shows a possible use of merge field's switches.

[C#] Example 2: Insert merge field with switches

editor.InsertField("MERGEFIELD First_Name \\b \"Mr. \" \\f \". \"", "");

See Also