Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Description

Excerpt

Sets an

Msdn
System.Collections.ICollection

...

System.Collections.ICollection
1ICollection
as a data source to bind to a specified set of main document merge fields.

Signature
C#
C#
 public void SetDataSource(System.Collections.ICollection dataSource, System.String[] fieldNames)
{signature}
{signature:
}
Signature
vb.net
vb.net
Public Sub SetDataSource(ByVal dataSource As System.Collections.ICollection, ByVal fieldNames As String())
{signature}
{parameters}
{param:dataSource}An {{ICollection}} to use as the data source.
{param}
{param:fieldNames}A string array of data source field names. These must be the same as the corresponding merge field names in the template.
{param}
{exceptions}
{exception:ArgumentNullException}[Save|WordTemplate.Save] will throw this exception if {{null}} \(C\#\) or {{Nothing}} \(VB.NET\) is passed to the method.
{exception}
{exception:ArgumentException}
{exception}
{remarks}This method takes a collection of values and an array of field names. The two must contain the same number of elements. Each name in the array of field names must be the same as the corresponding merge field name in the template.

Each merge field in a WordWriter template must bind to a data source field/value pair. The number of merge fields in the main template document \(the part of the document that is not within a repeat block\) may not exceed the number of values in the data source defined by [SetDataSource|WordTemplate.SetDataSource]. However, the number of values in the data source may be greater than the number of merge fields in the main template document.

{remarks}
{example}{code:csharp|title=C#}
Parameters
Param
dataSource
dataSource

An ICollection to use as the data source.

Param
fieldNames
fieldNames

A string array of data source field names. These must be the same as the corresponding merge field names in the template.

Exceptions
Exception
ArgumentNullException
ArgumentNullException

Save will throw this exception if null (C#) or Nothing (VB.NET) is passed to the method.

Exception
ArgumentException
ArgumentException

Remarks

This method takes a collection of values and an array of field names. The two must contain the same number of elements. Each name in the array of field names must be the same as the corresponding merge field name in the template.

Each merge field in a WordWriter template must bind to a data source field/value pair. The number of merge fields in the main template document (the part of the document that is not within a repeat block) may not exceed the number of values in the data source defined by SetDataSource. However, the number of values in the data source may be greater than the number of merge fields in the main template document.

Example
Code Block
csharp
csharp
titleC#


          wordTempl.SetDataSource(collValues, arrNames);
        
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}


          wordTempl.SetDataSource(collValues, arrNames)
        
{code} {example}