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 2 of 2 (23 items) < Previous 1 2
Sort Posts: Previous Next
  • 07-27-2009 02:09 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"))

    {

    }

    This is the code i am using to get the field's value.

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

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

     So I asked you to try this:

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

    And you continued to do this:

     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;

    and you simply tell me that it doesn't work?  Of course it doesn't work.  That's why I've given you different code to use three times, but you seem to be ignoring me and just using your own code over and over.  Are you trying to waste my time?

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

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

    Sorry to trouble you,

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

    if ((r == "S"))

    {

    }

    I tried above code but it was giving me an error "Object reference not set to an instance of an object". Then i used working with full Xpath.

     Thanks,

    Kalyan.

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

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

     Ok, thank you. Which node is the repeating one in your data source?  I guess it's item?  If that's the case, please try this:


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


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

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

     This is working fine Jimmy, we got the solution.

    Thanks alot for guiding me towards the solution.

  • 12-07-2011 12:21 PM In reply to

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

     Everytime I try this, it always pulls the first value.  If I have 3 instances and I click on the button on the 3rd row, the code always pulls values from the 1st row instance?  Why would this happen? 

    Here is the code I am using (InfoPath 2010)

    public void ApplyAccountingTreatmentToAll_Clicked(object sender, ClickedEventArgs e)
    {
    string teststr = e.Source.SelectSingleNode("Treatment", NamespaceManager).Value;
    MessageBox.Show(teststr.Value.ToString());
    }

  • 02-06-2012 02:13 PM 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've tried to do what you've mentioned here as well as how you've guilded countless others through the same issue. I've probably read at least 10 different instances where you've helped others but I still can't get this to work for me. Here is the scenario:

    Have two Filler Forms that are saved to a Form Library in SharePoint. One form is the master and the second is the details. On the master there is a repeating section (Master/Detail) that returns the detail records associated with the master. I've included a Button on the repeating table, inline with the data row. The idea is to have the button click open the detail record form. When I've hard coded the address of the detail form in the code the button has opened the detail record without issue.

    In order to do what I want to do the button click needs to aquire values related to the row it belongs to and feed the variables to additonal code, this works fine but only returns the 1st row detail record regardless of which row button is pressed.

    I've read countless articles, forum questions, blogs, and Microsoft articles but I still can't get this to work.

    Below is the code I'm using, in it are the multiple lines of code that failed, they return the error "Object reference not set to an instance of an object" when I try to do what all the different articles say to do. Note that all I'm trying to do here is get one fields value to appear in a MessageBox, purely to prove that the button click is retrieving data from the correct row. Once i've established I've got that part working I have the rest of the code ready but didn't want to include it so as not to confuse the issues.

            Public Sub CTRL152_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
                '
                Dim nsp As XmlNamespaceManager = Me.NamespaceManager
                Dim RowRec As XPathNavigator = e.Source.CreateNavigator()
                '
                'Dim mes As String = RowRec.OuterXml.ToString() *Returns values related to the correct row related to button clicked
                'Dim mes As String = RowRec.SelectSingleNode("/dfs:myFields/dfs:dataFields/ns1:SharePointListItem_RW/ns1:Sec_x0020_Code_x0020_Num", NamespaceManager).Value.ToString() *Return 1st Row data*
                '
                '
                'Dim mes As String = RowRec.SelectSingleNode("Sec_x0020_Code_x0020_Num", nsp).Value 'Error: Object reference not set to an instance of a object
                'Dim mes As String = RowRec.SelectSingleNode("@Sec_x0020_Code_x0020_Num", nsp).Value 'Error: Object reference not set to an instance of a object
                'Dim mes As String = RowRec.SelectSingleNode("../@Sec_x0020_Code_x0020_Num", nsp).Value 'Error: Object reference not set to an instance of a object
                'Dim mes As String = RowRec.SelectSingleNode("../../@Sec_x0020_Code_x0020_Num", nsp).Value 'Error: Object reference not set to an instance of a object
                'Dim mes As String = RowRec.SelectSingleNode("../../../@Sec_x0020_Code_x0020_Num", nsp).Value 'Error: Object reference not set to an instance of a object
                '
                MessageBox.Show(mes)
                '
            End Sub

    The strange thing is that If I use the "OuterXml.ToString()" then the code does return the data related to the row that hold the button that was pressed. Here is what is returned in the MessageBox from the OuterXML:

    If I use the full XPath to any field in the dataset, like: /dfs:myFields/dfs:dataFields/ns1:SharePointListItem_RW/ns1:Sec_x0020_Code_x0020_Num , then only the 1st row data is returned.

     It seems like no matter how I construct the XPath for the field, if I include the "@" infront of the field name I get the error. And only if I give the full XPath without the "@" will I get anything, and in that case its the 1st row.

  • 11-05-2013 08:48 PM In reply to

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

     Hello DanDeHaven,

    I know this is an ancient post and you have long since moved on to other challenges, but in the interest of helping others that might stumble upon this thread, the issue here is that you are missing the namespace prefix (you can see them in your messagebox). This should have worked:

        Dim mes As String = RowRec.SelectSingleNode("d:Sec_x0020_Code_x0020_Num", nsp).Value

     

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