Get specific field's value from a specific row in a repeating table using a button click programatically - InfoPath Dev
in

InfoPath Dev

Get specific field's value from a specific row in a repeating table using a button click programatically

Last post 11-05-2013 08:48 PM by Jimmy. 22 replies.
Page 1 of 2 (23 items) 1 2 Next >
Sort Posts: Previous Next
  • 07-24-2009 02:01 PM

    Get specific field's value from a specific row in a repeating table using a button click programatically

     

    Hi all,

                 I have an infopath form which is having a repeating table. From this repeating table i need to get a particular field's value based on button click, which is located in the same row. When i click the button i need to get the value from that field. I have a code here which is used to get the field's value based on button click.

     

    XPathNavigator xCheck = MainDataSource.CreateNavigator();

    XPathNodeIterator xNode = xCheck.Select("/dfs:myFields/dfs:queryFields/tns:method1/item", NamespaceManager);

    if

    ((xNode.Current.Select("/dfs:myFields/dfs:queryFields/tns:methods/item/field1", NamespaceManager)).ToString() != "")

    {

                   "code to be executed if the above condition is true"

    }

     

    This code is getting executed whenever the button is clicked.

    The problem here is,  I am able to get the value of that field from the first row. But if i click the button in the second row it's getting the field's value from the first row not from the current row.

    Any help would be greatly appreciated.

     

    Thanks,

    Kalyan.
    Filed under:
  • 07-27-2009 07:16 AM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

    I haven't still figure out the solution for my problem, please help.

    Thanks,

    Kalyan

  • 07-27-2009 08:38 AM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

     I already answered your question in this identical thread that you started:

    Re: Get the value of Specific field's value from a specific row in a repeating table programatically

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-27-2009 11:27 AM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

     Hi Jimmy,

      I tried that but i was able to find the current row. But here my case is different every time i enter a new row one field is taking the value from the first row it self. Actually here i am passing values from user view to manager view. If i leave the field empty in the current row then it's taking the value from the previous row. I have to do a validation on that particular field.

     

    Thanks,

    Kalyan.

  • 07-27-2009 11:40 AM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

     I'm afraid I have no idea what you just said.  It seemed in your original post that you wanted to get a value from the same row where a button was clicked.  Is that the case or not?  Could I see your latest attempt at the code?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-27-2009 12:20 PM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

    The scenario is completely different here. I have a repeating table which is having two columns, one column is having a drop down list box and the other contains a button called "Add row".  I have three values in that drop down list box, one is "--Select--" , second one is "A" and the final one if "B". I did a validation for the button like, when ever the user hit the add row button in the first row with out selecting A or B, it should show a pop up message. This is working fine for the first row, suppose if select "A" in the first row and hit "Add Row", it's working fine. Now i am in the second line where i did not select any value from the drop down. It should the take "--Select--" from the field as value, but it was taking "A" from the first row. It was always reading the value from the first row.

    Here is my code for this,

    XPathNavigator xCheck = MainDataSource.CreateNavigator();

    XPathNodeIterator xNode = xCheck.Select("/dfs:myFields/dfs:queryFields/tns:method/structure/item", NamespaceManager);

    string r = xNode.Current.SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:method1/structure/item/fields1", NamespaceManager).ToString();

    if ((xNode.Current.SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:method1/structure/item/field1", NamespaceManager)).ToString() != "S")

    {

    }

    In the above code, "S" means --select-- , and "item" is the repeating node, and string "r" is used to find which value is coming.

  • 07-27-2009 12:41 PM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

    It looks like you asked this question twice, and the duplicate got deleted and I responded to the duplicate.  Sorry for the confusion.  This is the response I made:

     ---------------

    If the button is in the repeating rows, e.Source should be an XPathNavigator to the repeating node.  Once you have that, you can use XPath selection to get the child node you want.  It will probably be something like:

    XPathNavigator field = e.Source.SelectSingleNode("item/field1", NamespaceManager);

    or maybe

    XPathNavigator field = e.Source.SelectSingleNode("field1", NamespaceManager);

    And these statements will return XPathNavigator objects.  If you want to access the value of a node, you will need to inspect field.Value; and if you want to set the value, use field.SetValue().  Using ToString() on an XPathNodeIterator won't get you any meaningful information.
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-27-2009 01:10 PM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

    I am still getting the same value which i have entered in the first row. 

    XPathNavigator xCheck = e.Source.SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:method1/structure/item", NamespaceManager);

    string r = xCheck.SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:method1/structure/item/field1", NamespaceManager).Value; if ((r == "S"))

    {

    }

  • 07-27-2009 01:14 PM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

     Why are you using

    "/dfs:myFields/dfs:queryFields/tns:method1/structure/item"

    When I suggested using

     "item/field1"

    or 

    "field1"

     Using an absolute path like you are will always yield the first item.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-27-2009 01:21 PM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

     I used both of them, they are returning the same value, which is from the first row.

  • 07-27-2009 01:24 PM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

     I find that hard to believe.  Could you show me what the code looks like when you do that?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-27-2009 01:30 PM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

     XPathNavigator xCheck = e.Source.SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:method1/structure/item/field1", NamespaceManager);

    string r = xCheck.SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:method1/structure/item/field1", NamespaceManager).Value;

    if ((r == "S"))

    {

    }

  • 07-27-2009 01:34 PM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

     

    kalyan@infopath:

     XPathNavigator xCheck = e.Source.SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:method1/structure/item/field1", NamespaceManager);

    string r = xCheck.SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:method1/structure/item/field1", NamespaceManager).Value;

    Now you're using the full path in two places.  What happens if you use

    string r = e.Source.SelectSingleNode("item/field1", NamespaceManager).Value;

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-27-2009 01:47 PM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

     First row's value in that field.

  • 07-27-2009 02:02 PM In reply to

    Re: Get specific field's value from a specific row in a repeating table using a button click programatically

     Could you show me the code you're using?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 2 (23 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.