Edit this page
Available for: UI for ASP.NET AJAX | UI for ASP.NET MVC | UI for WPF | UI for WinForms

Document Variables

Document variables provide a mechanism to store information in the document in a key-value format. The Document Variable field is a field element used to access and display the value, which corresponds to the given field-argument. The argument is the name of the variable.


RadFlowDocument has a DocumentVariableCollection property, which holds document variable records. The collection maps string keys to string values. You can add a record in it through an indexer or with the collection's Add() method. Example 1 demonstrates both approaches.

[C#] Example 1: Add document variable record

RadFlowDocument document = new RadFlowDocument();
document.DocumentVariables["Job"] = "Software Engineer";
document.DocumentVariables.Add("Name", "Nancy Davolio");

The code in Example 1 adds two document variables – "Name", which will be evaluated to "Nancy Davolio", and "Job" with "Software Engineer" value.

The same two methods can be used to modify the value of an existing variable in the collection.

Removing defined variables can be achieved by using the Remove() method of the variables collection. It accepts the name of the variable as a parameter.

[C#] Example 2: Remove document variable record



The syntax of a document variable field code is pretty simple as demonstrated on Figure 1.

Figure 1: Document variable field code syntax

Rad Words Processing Concepts Document Variables 01


A DocumentVariable field can be inserted through RadFlowDocumentEditor's InsertField() method. More information on fields is available in the Fields article. Example 3 shows insertion of the field created in Example 1.

[C#] Example 3: Insert document variable field

editor.InsertField("DOCVARIABLE Name", "Nancy Davolio");

See Also