delete a row in a repeating table - InfoPath Dev
in

InfoPath Dev

delete a row in a repeating table

Last post 04-21-2011 03:32 PM by Skarn. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-06-2011 10:16 AM

    delete a row in a repeating table

    Hello,

     I'm attempting to delete a row from a repeating table when a button is clicked. So far I have been unsuccessful in getting the code below to work. I'm not recieving any type of error but when the button is pressed nothing happens. Can someone let me know how to correct this?

     

    objXMLNode = XDocument.DOM.selectNodes("/dfs:myFields/dfs:dataFields/d:Contact_Member_Names/@Office");

     objXMLNode.removeAll();

  • 04-06-2011 11:53 AM In reply to

    Re: delete a row in a repeating table

    You need to specify the array item in the repeating element i.e. if Contact_Member_Names is repeating you'll need Contact_Member_Names[n] where n is the node position - you can check using position(). Also I'm guessing that d:Contact.... should read dfs:Contact.... Hope this helps.
  • 04-14-2011 12:23 PM In reply to

    • g21cincy
    • Top 150 Contributor
    • Joined on 10-20-2008
    • Cincinnati, OH
    • Posts 64

    Re: delete a row in a repeating table

    I've done this before using code behind a button in VB. I added a Remove field to the table I used for my repeating table.

    tblTest will be my example table

    ID is the primary key that increments by 1 for each row

    'table1' will be my data source used for the table using tblTest

    'table remove row' will be my data source used to make connection to tblTest

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

    Dim Nav As XPathNavigator = Me.DataSources("table1").CreateNavigator()

    Dim Conn As AdoQueryConnection = Me.DataConnections("table remove row")

    Dim rows As XPathNodeIterator = Nav.Select("/dfs:myFields/dfs:dataFields/d:tblTest", NamespaceManager)

    Dim iCounter As Integer = 1

    While rows.MoveNext()

    If GetValue("/dfs:myFields/dfs:dataFields/d:tblTest[" & iCounter & "]/@Remove", Nav) = "yes" Then

    Conn.Command = "DELETE FROM tblTest " & _

    "WHERE (ID = '" & GetValue("/dfs:myFields/dfs:dataFields/d:tblTest[" & iCounter & "]/@ID", Nav) & "')"

    Conn.Execute()

    End If

    iCounter += 1

    End While

    Hope this helps you out!

  • 04-21-2011 03:32 PM In reply to

    • Skarn
    • Top 50 Contributor
      Male
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    Re: delete a row in a repeating table

     This code must be in the click event of the button?

    I've always found I can use the eventObj object of the event to easily delete the repeating row/section.
    First, my remove button is usually inside the repeating section, or in an empty column at the end of the table, or next to the final control in the last column.


    Then I call something like eventObj.Source.nodeParent.removeChild(eventObj.Source);

     

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.