Append Child - InfoPath Dev
in

InfoPath Dev

Append Child

Last post 01-24-2012 03:57 PM by jaxkookie. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 01-24-2012 03:10 PM

    Append Child

    I know this is probablly a simple fix. I have a repeated section where user will add item details. the row has a button that is enabled once the section is complete. they click the button and it adds a row and field values to another repeating section on another view. On this view they can add cost and rates. I have successfully accomplished this, but the rates are being added in descending order. When I clone the table and set the value it is added to the first row. I am not sure why this is.  Here is my code, can someone see what I am missing?

    
    
    

    public void CreateRates_Clicked(object sender, ClickedEventArgs e)
            {
                XPathNavigator root = MainDataSource.CreateNavigator();
                XPathNavigator DOM = e.Source.CreateNavigator();
                XPathNavigator details = root.SelectSingleNode("/my:myFields/my:myRateDetails/my:CmdtyAssignmentGrp", NamespaceManager);
                XPathNavigator repTable = details.SelectSingleNode("my:CommodityAssignment[last()]", NamespaceManager);
               
                XPathNodeIterator rows = root.Select("/my:myFields/my:myRateDetails/my:CmdtyAssignmentGrp/my:CommodityAssignment", NamespaceManager);

                XPathNavigator rCount = root.SelectSingleNode("/my:myFields/my:myRateDetails/my:CmdtyAssignmentGrp/my:CommodityAssignment/my:rCount", NamespaceManager);

                XPathNavigator CmdtyRate = details.SelectSingleNode("/my:myFields/my:myRateDetails/my:CmdtyAssignmentGrp/my:CommodityAssignment/my:CmdtyRate", NamespaceManager);

                string LINum = DOM.SelectSingleNode("my:LINum", NamespaceManager).Value;
                string RateAssignmentDS = DOM.SelectSingleNode("my:RateAssignmentDS", NamespaceManager).Value;

                XPathNavigator node;

                    node = repTable.Clone();
                    details.AppendChild(node);

                    node.SelectSingleNode("my:CmdtyRow", NamespaceManager).SetValue(LINum);
                    node.SelectSingleNode("my:CmdtyRate", NamespaceManager).SetValue(RateAssignmentDS);
                    //node.SelectSingleNode("my:FieldC", NamespaceManager).SetValue("FieldC - Row " + i.ToString());

                    //details.AppendChild(node);

               
             //delete first blank row
                while (rows.MoveNext())
                {
                    string CurrentRow = rows.Current.SelectSingleNode("my:CmdtyRate", NamespaceManager).Value;
                    if (CurrentRow == null || CurrentRow == "")
                    {
                        rows.Current.DeleteSelf();
                        break;
                    }

                }
            }

    Kind regards,
    Larry
  • 01-24-2012 03:57 PM In reply to

    never mind, i figured it out. I change appendchild to insertafter and used MoveToNext before setting field values. Work perfectly.

    Kind regards,
    Larry
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.