MailMerge text prefix is gone

Hi,
I’ve created a mailmerge field with some text prefix.
e.g. Date: «Date»
When I try to replace the merge field with some data from the database, the text prefix is gone.
e.g.

builder.MoveToMergeField("Date");
builder.Write(dr["date"].ToString());

The output is just the value of date whereas I’d like the output to be
Date:
How to make sure the text prefix is retained ?
Thanks,
Kiran.

Hi Kiran,
The text outside of mail merge field should be preserved, only the field should be replaced. Please double check that your prefix stays outside of the merge field and attach your document to your post here to review.

Hi,
yes, the prefix does stay outside of the merge field and I’ve attached a simple template file with a few merge fields in. Please check it and let me know what I’m doing wrong.
Thanks,
Kiran.

No, the prefixes are within merge fields in your document, furthermore, merge fields contain text that duplicates their names. I’ve corrected the document and now it’s ready to work, see attached

ok, now the prefixed text and the merge field have no relation. I’d like the prefixed text to be displayed only when there is a value for the merge field. otherwise, I’d like the prefixed text to be gone when I delete the mergefields. is there a way to do this ?
Thanks,
Kiran.

Well if your document structure is similar to that of the sample document you attached, you can run something like this at the end of processing in order to clean up remaining merge fields and their owner paragraphs:

NodeList fields = doc.SelectNodes("//FieldStart");
foreach (FieldStart fieldStart in fields)
{
    if (fieldStrt.FieldType == FieldType.FieldMergeField)
        fieldStart.ParentNode.Remove();
}