Hi,
I found this code on this forum and it works great to get the number of repeating sections I need onto the form. I am now trying to get a number into the @QuestionNumber node in each repeating section. I can't seem to figure it out. Unfortunately, there are no errors given and the value is not inserted into the correct node. The part after Dim Qstn is the code in question. Thanks for helping me.
'set the query fields
Dim xpath As String = "/dfs:myFields/dfs:dataFields/d:Tests/@NumberofQuestions"Dim field As XPathNavigator = Me.DataSources("Tests").CreateNavigator().SelectSingleNode(xpath, NamespaceManager)
'get the node you wish to have repeated
xpath =
"/dfs:myFields/dfs:dataFields/d:Annual_Test_Results/d:AnnualTestAnswers"Dim group As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager)
'cast the field's value to an int to know how many rows to addDim rows As Integer = field.ValueAsInt
'loop, cloning group
Dim i As IntegerFor i = 1 To rows - 1Dim newRow As XPathNavigator = group.Clone()
newRow.InsertAfter(group)
Dim Qstn As XPathNavigatorQstn = group.CreateNavigator().SelectSingleNode(xpath & "/@QuestionNumber", NamespaceManager)
Qstn.SetValue(Convert.ToString(i))
Next i