Microsoft Office Tutorials and References
In Depth Information
Assigning a value to a node in the main data source
In some cases, the node value that your program is trying to retrieve will be relative
to a particular event object. In the FetchSingleNodeValue_MainDataSource
function, the event object is passed as an argument along with the XPath
statement to override this situation.
// Custom function to fetch the single node from main data source.
private string FetchSingleNodeValue_MainDataSource(string xPath,
XmlEventArgs objEventArg)
// Navigate through main data source using XMLeventarg.
XPathNavigator xNode = objEventArg.Site.SelectSingleNode(xPath,
return xNode.ToString();
Assigning a value to a node in the main
data source
The AssignNodeValue_ToMainDataSource function uses the first XPath statement
argument to identify an XPathNavigator object, and then assigns it to the value of
the second argument.
// Custom function
private string AssignNodeValue_ToMainDataSource(string xPath,
string strValue)
// Navigate through main data source
XPathNavigator xNode = MainDataSource.CreateNavigator().
SelectSingleNode(xPath, NamespaceManager);
return xNode.ToString();
// Button click event
public void btn_SetNodeValue_Clicked(object sender,
ClickedEventArgs e)
// Call the custom function to result the data & Passing parameter
string strResult = AssignNodeValue_ToMainDataSource("/my:
myFields/my:myChapterName", "Programming InfoPath");
MessageBox.Show("Assigned value is : " + strResult);
Search JabSto ::

Custom Search