There are multiple examples how to populate a repeating table from a Sharepoint List, so that's not the problem, but let me change scenario a bit.
I'd like to have a repeating section with a dropdown list and repeating table. Let's say I have Sharepoint List with 3 columns: Department, FirstName, LastName.
I want to populate the dropdown list with Departments and when an item is selected, to populate the repeating table with Names.
That all works fine but only in the first section. When I click on Insert new section and then select from the dropdown, nothing happens.
I guess the problem is in the AddItem code. Do I have to specify a current section's index and if yes, then how?
Private Sub AddItem(ByVal FName As String, ByVal LName As String)
Dim doc As XmlDocument = New XmlDocument()
Dim group As XmlNode = doc.CreateElement("Names", NamespaceManager.LookupNamespace("my"))
Dim field As XmlNode = doc.CreateElement("FirstName", NamespaceManager.LookupNamespace("my"))
Dim node As XmlNode = group.AppendChild(field)
node.InnerText = FName
field = doc.CreateElement("ListName", NamespaceManager.LookupNamespace("my"))
node = group.AppendChild(field)
node.InnerText = LName
doc.AppendChild(group)
MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Section/my:Group1/my:Group2", NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator())
End Sub