hi,
could you plese help why my code is not working and it is giving error OBJECT REFERENCE IS NOT SET TO AN INSTANCE OF THE OBJECT . error while binging the merge fild with empty of dataset row
Aspose.Words.Node parentRow = e.Field.Start.GetAncestor(typeof(Row));
parentRow.Remove();
this is my mergefieldevent args is
void mailmergeEvent(object sender, MergeFieldEventArgs e)
{
if (string.IsNullOrEmpty(e.FieldValue.ToString()) || e.FieldValue == DBNull.Value)
{
Aspose.Words.Node parentRow = e.Field.Start.GetAncestor(typeof(Row));
parentRow.Remove();
}
}
Hi
Thanks for your inquiry. This occurs because current field is not placed in table. So GetAncestor(NodeType.Row) returns null. You should use the following code:
void MailMerge_MergeField264(object sender, MergeFieldEventArgs e)
{
if (string.IsNullOrEmpty(e.FieldValue.ToString()))
{
Aspose.Words.Node parentRow = e.Field.Start.GetAncestor(NodeType.Row);
if (parentRow != null)
parentRow.Remove();
}
}
Hope this helps.
Best regards.
hi Alexey,
you have given to my problem and one thing is remained from WordDownlods… that is when i insert pagebreak one blank page is comming how to remove. i have attached my template. in that i am getting blank page after DownloadResult heading. can you plese go through it and give me solution…
Hi
Have you tried to use the template I attached in the following thread?
https://forum.aspose.com/t/106003
I think this should solve your problem.
Best regards.