Extracting fields value in code C# - InfoPath Dev
in

InfoPath Dev

Extracting fields value in code C#

Last post 08-22-2016 07:47 AM by Varmond. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-09-2016 02:28 PM

    Extracting fields value in code C#

    I'm trying to extract a controls fields value in C#, here is the following code: public void CTRL128_14_Clicked(object sender, ClickedEventArgs e) { //Declare our variables string fileName; XPathNavigator nameNode; //Set the values. Replace "/my:myFields/my:textField" with the xpath to the field that has the value you want as the file name nameNode = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Counter_Awareness", NamespaceManager); fileName = nameNode.Value; string fileName2; XPathNavigator nameNode2; //Set the values. Replace "/my:myFields/my:textField" with the xpath to the field that has the value you want as the file name nameNode2 = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:SumAll_Counters1.1", NamespaceManager); fileName2 = nameNode2.Value; { if (fileName >= fileName2) { DialogResult result = MessageBox.Show("Awareness is not accompanied by another solution that is implemented, do you still want to submit this form?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { DataConnection spConn = DataConnections["SharePoint Library Submit"]; spConn.Execute(); Application.ActiveWindow.Close(); // Esto cierra la aplicacion } else if (result == DialogResult.No) { //code for No } } } } It's suppose to compare two values and if filename one is greater then filename2, a messagebox is suppose to appear for the user. I keep getting problems with the operator saying that: "Error 1 Operator '>=' cannot be applied to operands of type 'string' and 'string'. I tried using integer values but no luck.
  • 08-09-2016 02:40 PM In reply to

    Re: Extracting fields value in code C#

    Continuation of code
  • 08-15-2016 08:20 AM In reply to

    Re: Extracting fields value in code C#

     You'll need to convert those two strings to integers (or decimals, whatever they are) in order to compare with greater than / less than. I use TryParse() usually. You can find samples here: https://msdn.microsoft.com/en-us/library/f02979c7(v=vs.110).aspx

    Hilary Stoupa

  • 08-22-2016 07:47 AM In reply to

    Re: Extracting fields value in code C#

    I was able to find a solution a few days ago, Thanks a ton Hillary!!!
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.