Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XmlFormView not updating/refreshing correctly

Status
Not open for further replies.

fahlen

Programmer
Nov 28, 2006
5
ES
Hi,

I have created an InfoPath form which populates a drop-down list box with data from a web service when the form loads. Then, I've added code that executes on the Changed event for this list box. This code updates the rest of the form, querying a web service (passing the current value of the list box as a parameter).

This is the code:


public void pending_Changed(object sender, XmlEventArgs e)
{
// Write your code here to change the main data source.

// Get hold of the datasource for the webservice operation
DataSource ds = this.DataSources["GetExpense"];

// Create an XPathNavigator to the node we have to set to query the method
XPathNavigator guidField = ds.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:GetExpense/tns:guid", this.NamespaceManager);

// Set the query value to the current Guid
guidField.SetValue(e.NewValue);

// Execute the webservice operation
ds.QueryConnection.Execute();

// The data will now be in the datasource
XPathNavigator entryNavigator = this.DataSources["GetExpense"].CreateNavigator();

// Add the namespaces so we can query the datasource
XmlNamespaceManager umanager = new XmlNamespaceManager(entryNavigator.NameTable);
umanager.AddNamespace("dfs", " umanager.AddNamespace("tns", " umanager.AddNamespace("my", " umanager.AddNamespace("xd", "
// Get hold of the node we're after
XPathNavigator formNode = entryNavigator.SelectSingleNode("/dfs:myFields/dfs:dataFields/tns:GetExpenseResponse/my:GetExpenseResult", umanager);

// Set values of name and date
this.CreateNavigator().SelectSingleNode("/my:myFields/my:name", this.NamespaceManager).SetValue(
formNode.SelectSingleNode("//my:name", umanager).ToString());
this.CreateNavigator().SelectSingleNode("/my:myFields/my:date", this.NamespaceManager).SetValue(
formNode.SelectSingleNode("//my:date", umanager).ToString().Substring(0, 10));

this.CreateNavigator().SelectSingleNode("/my:myFields/my:mileageCost", this.NamespaceManager).SetValue(
formNode.SelectSingleNode("//my:mileageCost", umanager).ToString().Replace('.', ','));

// Update repeating table with new data
XPathNavigator ipRepTable = this.CreateNavigator().SelectSingleNode("/my:myFields/my:group1", this.NamespaceManager);
XPathNavigator wsRepTable = formNode.SelectSingleNode("//my:group1", umanager);
ipRepTable.ReplaceSelf(wsRepTable);
}



This works just fine when the form is executed in InfoPath. However, when I publish the form to Office Forms Server (SharePoint) and embed the form in a Web Form using the XmlFormView control, things get more difficult. Well, actually the only problem is that when the selected item in the list box changes, the code for updating the contents of the form is executed, but the form as presented in the browser isn't updated.

I encounter a similar problem when using repeating tables. For the first row, which loads by default when the form is first loaded, formulas and type validation is performed correctly, but when I add more rows, nor formulas nor validations is performed.

If I click on "Print preview", I get the message:

"The form contains changes that must be processed before it can be printed. Click OK to update the form, and then try printing again."

I click OK, and the form is refreshed, showing me the correct data.

How can I trigger this update/refresh of the XmlFormView control in code? There has to be a way of doing this, I just haven't figured out how yet.

I hope someone will be able to give me a hint.

Thanks in advance,
Markus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top