I have a repeating table in a List view where each row has a button that when clicked should switch to an Edit view while loading the selected row details. Based on a lot of research and postings I see that there are two ways to accomplish this. One is to put a action rule on the button and the other is custom code tied to the Click event of the button.
My problem is that neither of these solutions seems to work..and for slightly different reasons. The underlying issue is that I cannot seem to extract the field that holds the row id so I can then pass it on the the new view.
The data coming in is via a web service and has the following XPath (not sure if that is the correct terminology) --
myField / dataFields / tns:GetItemsResponse / GetItemsResult / q1:Item / ReferenceId
myField / dataFields / tns:GetItemsResponse / GetItemsResult / q1:Item / field2
myField / dataFields / tns:GetItemsResponse / GetItemsResult / q1:Item / field3
myField / dataFields / tns:GetItemsResponse / GetItemsResult / q1:Item / ...
Action Rule
The rule tries to set a queryField field on a Secondary connection using the following expression
current()/ReferenceId
However, when I run it I get the following very unhelpful error message
Some rules were not applied.
Unspecified error
If I set the expression to just
current()
I get back all the values from all the fields as a single concatenated value. This seems to indicate that current() does have the correct row referenced but I just cannot seem to get a specific field.
Code
Meanwhile, the following code pops up an Object reference not set set to an instance of an object
exception
Public Sub EditItemButton_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
Dim sourceNav As XPathNavigator = e.Source.CreateNavigator()
MessageBox.Show(sourceNav.InnerXml)
Dim idNav As XPathNavigator = sourceNav.SelectSingleNode("ReferenceId", Me.NamespaceManager)
MessageBox.Show(idNav.InnerXml)
End Sub
The first MessageBox call (for sourceNav) shows the XML for the currently selected row. And I see the ReferenceId node in there. But again, I cannot seem to get access to it via the SelectSingleNode.
I have tried all different combinations of ReferenceId including "../ReferenceId"
, "q1:ReferenceId"
(that is what shows in the designer and when I copy the XPath), "a:ReferenceId"
(the "a:" is what shows when the sourceNav.InnerXml is displayed..but I do not understand why...)
Any thoughts or ideas?
Thanks.