Here is the code in the app for saving the new results:
//Reload the current response, which is necessary because the response object does not have a lifecycle
// beyond the a single postback in the application. This will eventually change, but for now the
// response must be reloaded to prevent item IsValid states from getting confused.
LoadCurrentResponse();
bool valid = true;
if (_itemRenderers != null)
{
foreach (ItemRenderer renderer in _itemRenderers)
{
//Update the model
renderer.UpdateModel();
if (renderer.Model is ResponseItem)
{
valid = valid & ((ResponseItem)renderer.Model).Valid;
}
//Rebind the renderer to the model to cause the validation errors to show
// current state of the Model.
renderer.BindModel();
}
_answersUpdatedLbl.Visible = valid;
_validationErrorLbl.Visible = !_answersUpdatedLbl.Visible;
//Save the response state
CurrentResponse.SaveCurrentState();
}
After trying several things, I found that if I commented out the LoadCurrentResponse(); the new answers were saved correctly, and everything else still appears to work.
|