Afternoon everyone
I hope someone can help me, what I've got is a repeating table with 2 buttons at the top of the screen. the first button shows the table (by default the repeating table is hidden) the second button hides the table and removes all the rows using this vb code:
Public Sub ButtonMiscExpensesNo_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
' Retrieve a reference to the Main DOM
Dim root As XPathNavigator = MainDataSource.CreateNavigator()
' Count the amount of group2 nodes
Dim iter As XPathNodeIterator = root.Select( _
"/my:myFields/my:MiscExpensesSection/my:MiscExpenseTable/my:MiscEntertainmentExpenses", _
NamespaceManager)
Dim group2NodesCount As Integer = iter.Count
' Retrieve the first group2 node
Dim firstGroup2NodeNav As XPathNavigator = _
root.SelectSingleNode("/my:myFields/my:MiscExpensesSection/my:MiscExpenseTable/my:MiscEntertainmentExpenses[1]", _
NamespaceManager)
' Retrieve the last group2 node
Dim lastGroup2NodeNav As XPathNavigator = _
root.SelectSingleNode("/my:myFields/my:MiscExpensesSection/my:MiscExpenseTable/my:MiscEntertainmentExpenses[" & _
group2NodesCount.ToString() & "]", _
NamespaceManager)
' Delete the range of nodes from the first to the last group2 nodes
firstGroup2NodeNav.DeleteRange(lastGroup2NodeNav)
End Sub
This hides the table once the rows have been deleted. The reason they get deleted is so the fields are fresh incase the user changes his/her mind again and want to use the repeating table. Does anyone know what code I should add (in VB please) to add a row to the table using the button that shows the table? The code below doesn;t work and complains about incorrect data type and no matter what I try it just fails :0(
Dim myNamespace As String = NamespaceManager.LookupNamespace("my")
Using writer As XmlWriter = MainDataSource.CreateNavigator().SelectSingleNode( _
"/my:myFields/my:MiscExpensesSection/my:MiscExpenseTable", NamespaceManager).AppendChild()
writer.WriteStartElement("MiscEntertainmentExpenses", myNamespace)
writer.WriteElementString("MiscEntertainmentDate", myNamespace, "")
writer.WriteElementString("MiscEntertainmentExpense", myNamespace, "")
writer.WriteElementString("MiscEntertainmentNet", myNamespace, "0")
writer.WriteEndElement()
writer.Close()
End Using
Any hints or pointers will be appreciated.
Thanks in advanc
James