Not sure if the title is the correct term for this, but i want to replicate the mailmerge style functionality in one of my apps.
In other words, i would like to bind a keyword to a database field. For instance, whilst writing a description for a new stock item i could use:
"This {{title}} is available in {{colour1}} or {{colour2}}"

And the relevant fields would replace what is inside the double curly bracers.
What would be the best way to handle this. Is there any system designed for this or would i be best off parsing the text and making the relevant database calls myself?

Correct me if I am wrong. I suggest you to use an expression field.

DataTable dt = new DataTable();
            dt.Columns.Add("Expression", typeof(string), "'This ' +Title + ' is available in ' + Colour1 + ' or ' + Colour2");

Sorry, i probably didnt give enough details. I want the user to be able to type the description into a textbox/richtextbox in a designer. I then want to store their design with the keywords.
But i need to be able to output the description with the correct values.

The same way that you can write and save a letter in MS Word with <<Address Line 1>> in it. Then you assign a collection of addresses which basically match data to each keyword field (eg <<Address Line 1>> = "123 The Road").
When you print it replaces the keywords with data for each record.

I can manually parse the description and replace the keywords with the correct values, but i was wondering if there was a quicker more efficient way to do it.

This article has been dead for over six months. Start a new discussion instead.