IDataDispatcherOptions.DataSourceName Property
Specifies the name of a data source used for mail merge.
Namespace: DevExpress.Snap.Core.Options
Assembly: DevExpress.Snap.v21.2.Core.dll
NuGet Package: DevExpress.Snap.Core
Declaration
Property Value
Type | Description |
---|---|
String | A String value, specifying the data source name. |
Remarks
The IDataDispatcherOptions interface is implemented in the SnapMailMergeVisualOptions class and the DataSourceName property is accessible with the SnapControl.Options.SnapMailMergeVisualOptions.DataSourceName notation.
Set this option to enable the “Use for Mail Merge” option in Data Explorer for the specified data source, as illustrated in the following picture.
If there is a data source specified with the SnapControl.DataSource property, set the DataSourceName property to any value to enable mail merge for this data source.
To use a data source from the SnapControl.DataSources collection for a mail merge data source, assign the name of the data source to the DataSourceName property.
Note
The SnapControl.DataSources collection belongs to a document loaded in the control. When another document is loaded or a new document is created, the control prompts the user whether to maintain the data source connections that exist in the currently open document. If the answer is no, the SnapControl.DataSources collection is cleared and populated with data sources contained in the loaded document. For the new document, only the data source specified with the SnapControl.DataSource property is available.
Example
Set the IDataDispatcherOptions.DataSourceName
property to the name of the data source (the DataSourceInfo.DataSourceName property) to use the data source for mail merge.
Note
We do not recommend using data sources which are not marked as Use for Mail Merge to perform mail merge.
// Set the Application data source which cannot be edited or removed by the end-user.
this.snapControl1.DataSource = dsContacts.Tables[0];
// Add Document data sources which persist for the currently loaded document only.
this.snapControl1.Document.BeginUpdateDataSource();
this.snapControl1.Document.DataSources.Add("Products", products);
this.snapControl1.Document.DataSources.Add("Categories", categories);
this.snapControl1.Document.DataSources.Add("Sales", myExcelSource);
this.snapControl1.Document.EndUpdateDataSource();
// Set the default (Application) data source as the mail merge source ("Use for Mail Merge" option).
this.snapControl1.Options.SnapMailMergeVisualOptions.DataSourceName = "";
// Uncomment the following line to set the Sales data source as the mail merge source.
// this.snapControl1.Options.SnapMailMergeVisualOptions.DataSourceName = "Sales";