Hi all -
This should be a really simple bit of code, but I can't understand why it's not working.
All I want to do is retrieve a value from one field and set another's fields value depending on the first.
Here is the code:
Public Sub Q_Select_1_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)
Set_Weighting(
"1")
End SubPublic Sub Set_Weighting(QNo as String)
' Get question number and questionDim QuestionString As String = String.Concat("//my:myFields/my:Questions/my:Q_Select/my:Q_Select_", QNo)
Dim WeightingString As String = String.Concat("//my:myFields/my:Questions/my:Q_Weighting/my:Q_Weighting_", QNo)
Dim WeightingValue As Integer
'Get value of Q_SelectDim nav As XPathNavigator = MainDataSource.CreateNavigator()
Dim fieldValue As String = nav.SelectSingleNode(QuestionString, NamespaceManager).Value
'Select case from string in Q_SelectSelect Case fieldValue
Case "Yes"
WeightingValue = 100
Case "No"
WeightingValue = 0
Case "To be reviewed"
WeightingValue = 25
Case "Not required"
WeightingValue = 100
Case "In Progress"
WeightingValue = 50
Case "Awaiting Sign Off"
WeightingValue = 75
Case "Information not available"
WeightingValue = 0
Case "Immediate action required"
WeightingValue = 0
End Select
'Set Q_Weighting valueDim nav2 As XPathNavigator = MainDataSource.CreateNavigator()
nav2.SelectSingleNode(WeightingString, NamespaceManager).SetValue(WeightingValue)
End Sub
It just throws an InvalidOperationException error. When I hover over WeightingString, the xpath is as it should be. The WeightingValue is also correct. Can anyone see what the problem is? I have tried different permutations of the xpath, but nothing seems to work.
TIA