Purpose: User clicks Button "Augmentin"; code then populates 4 fields in a new row of repeating table.
Paradigm: 1. Add a new row.; then count the number of rows and position navigator on last (new) row. Then add field values
Here is the code:
Public Sub btnAugmentin_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
' Write your code here.
'add a new row....
CurrentView.ExecuteAction(ActionType.XCollectionInsert, "group96_294")
Dim i As Integer
Dim RXnav As XPathNavigator = MainDataSource.CreateNavigator()
'create a navigator to iterate through the table
Dim RxRows As XPathNodeIterator = RXnav.Select("/my:myFields/my:Exam/my:grpRXHeader/my:grpRX", NamespaceManager)
'get a count of rows
i = 0
While RxRows.MoveNext()
i = i + 1
End While
'position on the last row of the table
Dim RxRow As XPathNavigator = RXnav.SelectSingleNode("/my:myFields/my:Exam/my:grpRXHeader/my:grpRX[ " & i.ToString & "]", NamespaceManager)
'get a reference to the field "cboDrug"
Dim Rxfield As XPathNavigator = RxRow.SelectSingleNode("./my:cboDrug", NamespaceManager)
'set the value of the field
Rxfield.SetValue("Augmentin")
'..............so far so good..........................
'now set the value of field "cboRxquantity" to 20
Rxfield = RxRow.SelectSingleNode("./my:cboRXQuantity", NamespaceManager)
'code fails at next line....reference is invalid
Rxfield.SetValue("20")
Issues are: how to all the other fields on the new row
other issue: how to use the "addchild" method to add a row rather than the XcollectionInsert
Thanks in advance to anyone who answers!!
Adam