Hi,
I have a browser enabled form template based on a webservice that is connected to a SQL database.
On my form I have a simple dropdown box, which when a certain value is selected requires a new part of the form to appear and be filled in.
The easy way to do this seemed to be Conditional Formatting, however, because the form is connected to database via a webservice, the table that this part of the form relates to has no new row that relates to the rest of the form, therefore the section will not appear automatically. All I get is the link to "Click here to insert". This is the same for all the sections in our form, but for the sections that have been required to display at Form Load, we have added SQL triggers that inject the new row into the correct table and the form automatically displays the section with the Default Values entered in the table by SQL.
Ideally I'd simply like to have a rule that when "ClientType" has a certain value selected, the new section appears all on it's own. Currently the link simply appears and disappears with the conditional formatting.
Is there a way to programmatically add the section as if someone had just clicked the "Click here to insert" link? Failing this, is there a way to force a value into a field, so that when the Client Type is selected the section appears automatically?
I have been looking at this approach which gave me this code
Public Sub TempleType_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)
Dim ClientType As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/tns:GetFormDatasetResponse/tns:GetFormDatasetResult/ns1:dsForms/ns1:Clients/ns1:TempleType", NamespaceManager)
Dim Username As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:GetFormDataset/tns:pUserLoginId", NamespaceManager)
' Move to the root element of the document
Dim root As XPathNavigator = Me.MainDataSource.CreateNavigator()
root.MoveToFollowing(XPathNodeType.Element)
' Get an XPathNavigator pointing to the parent node where the repeating elements will be added
Dim sectionNode As XPathNavigator = root.SelectSingleNode("/dfs:myFields/dfs:dataFields/tns:GetFormDatasetResponse/tns:GetFormDatasetResult/ns1:dsForms/ns1:SelfGeneratedCases", Me.NamespaceManager)
Dim ns As String = sectionNode.NamespaceURI
' Add the XML tree for the child element
Using writer As XmlWriter = sectionNode.AppendChild()
writer.WriteStartElement("my", "SelfGeneratedCases", ns)
writer.WriteElementString("my", "ChangeBy", ns, Username.Value)
writer.WriteEndElement()
End Using
End Sub
But currently I am getting a NullReferenceException on this line
Dim ns As String = sectionNode.NamespaceURI
Any help anyone could give me on this is hugely appreciated as it's pretty urgent.
Thanks