Data Does Not Bind in WFDataBindingControl when Populating the Values During Page Load

Applies To

Symptoms

In ASP.NET, if you create a web control such as wfDropDownList and populate it by hard-coding the option values under the control's collection object, binding works as expected (the mapped field is selected on the correct value).

However, if I populate the list of items by performing a data bind in the page's load event, it doesn't recognize the binding of the mapped field.

Cause

The values of WFDataBindingControl controls are normally loaded from the workflow DB automatically as part of the page's lifecycle, during the page's Init phase. However, when you dynamically create the controls and add them to the page after the Init phase of the page's lifecycle, the controls' data will not be automatically loaded because it was not present when the page loaded the data. Therefore, the list value must be populated before OnInit(), or the mapped field will not be bound.

Resolution

Populate the list values before the OnInit() call. To do this, y ou can call the page's protected "UpdateBindingControls()" method after you have finished creating your dynamic controls and inserting them into the page's control hierarchy. Calling this method manually will reload the data for all of the page's WFDataBindingControl controls.

Also, the values of WFDataBindingControl controls are normally saved to the workflow DB automatically as part of the page's "CompleteWorkItem()" method. However, you can also save the values without completing the work item by calling the pages protected "WriteBindingControls()" method.