# MailMerge.MergeBlocks Method

> Merges all repeating blocks that are contained in the loaded template with the System.Data.DataTable instances contained in the given System.Data.DataSet. The name of the System.Data.DataTable must match the name of the block in the template. The supported format of the repeating blocks can be found in the ASP.NET User's Guide.

> **Note:** This is deprecated and should not be used in new work.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 14.0
- **Obsolete:** the assembly marks this as obsolete
- **Namespace:** `TXTextControl.DocumentServer`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXDocumentServer.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXDocumentServer.dll` from the setup
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl.DocumentServer > MailMerge.MergeBlocks Method
- **974 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/mergeblocks-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/mergeblocks-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/mergeblocks-method/llms-full.txt

---

### Description

Merges all repeating blocks that are contained in the loaded template with the `System.Data.DataTable` instances contained in the given `System.Data.DataSet`. The name of the `System.Data.DataTable` must match the name of the block in the template. The supported format of the repeating blocks can be found in the ASP.NET User's Guide.

### Syntax

```csharp
[Obsolete]
public int MergeBlocks(DataSet mergeData);
```

```vbnet
<Obsolete>
Public Function MergeBlocks(mergeData As DataSet) As Integer
```

### Parameters

| Parameter | Description |
|---|---|
| mergeData | Specifies a `System.Data.DataSet` that contains the merge data. |

### Return Value

Returns the number of successfully merged blocks.

### Examples

The following example merges a block in a template.

```csharp
DataSet mergeData = new DataSet();

DataTable blockData = new DataTable("section1");
blockData.Columns.Add("name");
blockData.Columns.Add("company");
blockData.Rows.Add(new object[] { "Peter Jackson", "Text Control GmbH" });
blockData.Rows.Add(new object[] { "Jack Peterson", "The Imaging Source LLC" });

mergeData.Tables.Add(blockData);
mailMerge1.MergeBlocks(mergeData);
```

```vbnet
Dim MergeData As New DataSet()

Dim BlockData As New DataTable("section1")
BlockData.Columns.Add("name")
BlockData.Columns.Add("company")
BlockData.Rows.Add(New Object() {"Peter Jackson", "Text Control GmbH"})
BlockData.Rows.Add(New Object() {"Jack Peterson", "The Imaging Source LLC"})

MergeData.Tables.Add(BlockData)
MailMerge1.MergeBlocks(MergeData)
```

The following example uses Merge Blocks in a focused Mail Merge workflow.

```csharp
var result = mailMerge.MergeBlocks(new System.Data.DataSet());
Console.WriteLine($"Merge Blocks result: {result}");
```

```vbnet
Dim result = mailMerge.MergeBlocks(New System.Data.DataSet())
Console.WriteLine($"Merge Blocks result: {result}")
```

---

## Nearby

- **Previous:** [MailMerge.MergeBlockNamePrefix Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/mergeblocknameprefix-property/llms-full.txt)
- **Next:** [MailMerge.MergeCulture Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/mergeculture-property/llms-full.txt)
