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;
}
}
}