Hi Manikandan,
the sample you provided is almost perfect, but I'm looking for a more generic solution.
In the solution, you have provided (which works great BTW), I need to swap data source of the mail merge.
To do this I need to create a list of objects that has an object with the same field as my original data table - my data table has "Podmiot" field, and OrderDetails has "Podmiot" field.
Would it be possible to not create a new object or do it dynamically?
I've tried creating DataTablein this way:
var dt = new DataTable();
dt.Columns.Add(args.FieldNames[0]);
var row = dt.NewRow();
row[0] = "No Record Found";
dt.Rows.Add(row);
but I must return IEnumerable instead of DataTable.
EDIT:
I was able to get the results I need using below code:
private static void MailMerge_BeforeClearGroupField(object sender, BeforeClearGroupFieldEventArgs args)
{
Debug.WriteLine(args);
var alt = new ExpandoObject();
var expandoDict = (IDictionary) alt;
expandoDict.Add(args.FieldNames[0], "No Record Found");
args.AlternateValues = new List<object> {alt};
}