This is a migrated thread and some comments may be shown as answers.

Manipulating MergeField Codebehind

2 Answers 91 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Raimund
Top achievements
Rank 1
Raimund asked on 20 Aug 2011, 10:02 AM
Hello,

does someone knows a way how to access and change a value of a MergeField in codebehind?
I dont want to bind this Object to a datasource - the functionality should be like this
mergeField["Name"] = "Raimund Rittnauer";

To create new MergeFields and fill them with custom values.

Maybe someone knows how I can use MergeFields in this way.

Best regards,
Raimund

2 Answers, 1 is accepted

Sort by
0
Alex
Top achievements
Rank 2
answered on 22 Aug 2011, 02:40 PM
Hi Raimund,

    Do you need to do this multiple times or just one time at startup ? If you just need to do it one time at the beginning I might be able to help you. 
    Basically what I do is create a list of Dictionary<string,string> in which and then using reflection create a type(the type has properties with the names of the keys in the dictionary) and then a list of objects of that type(one new instance of the type for each Dictionary) and then feed that list tot he ItemsSource.
 
If this helps I can send you the code.

Alex.
0
Boby
Telerik team
answered on 25 Aug 2011, 07:45 AM
Hello Alex,
Evaluatation of merge fields values is performed within the MailMerge method of RadDocument or RadRichTextBox, using the values from RadDocument.MailMergeDataSource.ItemsSorce; it cannot be done without setting the ItemsSource.

Kind regards,
Boby
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
RichTextBox
Asked by
Raimund
Top achievements
Rank 1
Answers by
Alex
Top achievements
Rank 2
Boby
Telerik team
Share this question
or