Thank you
The code for the checkbox is:
Try
' Get a reference to the form's XmlNamespaceManager object.
Dim ns As XmlNamespaceManager = Me.NamespaceManager
' Create an XPathNavigator object for the form's main data
' source.
Dim xnDoc As XPathNavigator = Me.MainDataSource.CreateNavigator()
' If the check box is set to true, add a new row so the user
' can add a new contact.
If e.Site.Value = "true" Then
Dim xnTable As XPathNavigator = xnDoc.SelectSingleNode("/my:myFields/my:gpContacts", ns)
xnTable.AppendChild("")
Else
' If the user clears the check box, remove the added row.
ClearEnteredValues(xnDoc)
End If
Catch ex As Exception
MessageBox.Show("The following error occurred: " + ex.Message)
Throw
End Try
This is the code for the Cleared Event (for the checkbox)
Private Sub ClearEnteredValues(xnDoc As XPathNavigator)
Try
' Get a reference to the form's XmlNamespaceManager object.
Dim ns As XmlNamespaceManager = Me.NamespaceManager
' Create an XPathNodeIterator object to get a count of the
' rows in the repeating table used to add new Contacts.
Dim xi As XPathNodeIterator = xnDoc.[Select]("/my:myFields/my:gpContacts/my:gpContact", ns)
Dim rowCount As Integer = xi.Count
If rowCount > 0 Then
' Get the first and last rows (nodes) in the
' repeating table.
Dim firstNode As XPathNavigator = xnDoc.SelectSingleNode("/my:myFields/my:gpContacts/my:gpContact[1]", ns)
Dim lastNode As XPathNavigator = xnDoc.SelectSingleNode("/my:myFields/my:gpContacts/my:gpContact[" & rowCount & "]", ns)
' Delete the existing nodes using the DeleteRange method.
firstNode.DeleteRange(lastNode)
End If
' Clear the check box.
xnDoc.SelectSingleNode("/my:myFields/my:AddContacts", ns).SetValue("false")
Catch ex As Exception
MessageBox.Show("The following error occurred: " + ex.Message)
Throw
End Try
End Sub
This is the code for the Submit button
Try
' Get a reference to the form's XmlNamespaceManager object.
Dim ns As XmlNamespaceManager = Me.NamespaceManager
' Create a DataSource object for the MyContacts
' list data connection.
Dim dsContacts As DataSource = Me.DataSources("MyContacts")
' Create an XPathNavigator object for the MyContacts
' data connection.
Dim xnContacts As XPathNavigator = dsContacts.CreateNavigator()
' Create an XPathNodeIterator object for the MyContacts
' data connection to enumerate the existing contacts.
Dim xiContacts As XPathNodeIterator = xnContacts.[Select]("/dfs:myFields/dfs:dataFields/dfs:MyContacts", ns)
' Create a DataSource object for the Add List Item Template
' data connection.
Dim dsCAML As DataSource = Me.DataSources("Add List Item Template")
' Create an XPathNavigator object for the
' Add List Item Template data connection.
' This is used to set the values in the CAML XML file.
Dim xnCAML As XPathNavigator = dsCAML.CreateNavigator()
' Create a WebServiceConnection object for submitting
' to the Lists Web service data connection.
Dim wsSubmit As WebServiceConnection = DirectCast(Me.DataConnections("Web Service Submit"), WebServiceConnection)
' Create an XPathNavigator object for the form's
' main data source.
Dim xnDoc As XPathNavigator = Me.MainDataSource.CreateNavigator()
' Create an XPathNodeIterator object for the new contacts.
Dim xiNewContacts As XPathNodeIterator = xnDoc.[Select]("/my:myFields/my:gpContacts/my:gpContact", ns)
' See if any new contacts have been added.
If xiNewContacts.Count > 0 Then
While xiNewContacts.MoveNext()
' Set the values in the Add List Item Template
' XML file using the values in the new row.
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='Title']", ns).SetValue(xiNewContacts.Current.SelectSingleNode("my:Title", ns).Value)
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='FirstName']", ns).SetValue(xiNewContacts.Current.SelectSingleNode("my:FirstName", ns).Value)
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='LastName']", ns).SetValue(xiNewContacts.Current.SelectSingleNode("my:LastName", ns).Value)
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='Phone']", ns).SetValue(xiNewContacts.Current.SelectSingleNode("my:Phone", ns).Value)
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='Email']", ns).SetValue(xiNewContacts.Current.SelectSingleNode("my:Email", ns).Value)
' Set the values of the Changed and Delete columns to
' "FALSE".
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='Changed']", ns).SetValue("FALSE")
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='Delete']", ns).SetValue("FALSE")
' Set the value of Cmd attribute to "New".
xnCAML.SelectSingleNode("/Batch/Method/@Cmd", ns).SetValue("New")
' Submit the new row.
wsSubmit.Execute()
End While
Else
' Enumerate the existing contacts and see if
' any items have been changed or set to be deleted.
While xiContacts.MoveNext()
If xiContacts.Current.SelectSingleNode("@Changed", ns).Value = "true" Then
' Set the values in the Add List Item Template XML file
' to the values in the updated row.
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='Title']", ns).SetValue(xiContacts.Current.SelectSingleNode("@Title").Value)
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='FirstName']", ns).SetValue(xiContacts.Current.SelectSingleNode("@FirstName").Value)
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='LastName']", ns).SetValue(xiContacts.Current.SelectSingleNode("@LastName").Value)
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='Phone']", ns).SetValue(xiContacts.Current.SelectSingleNode("@Phone").Value)
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='Email']", ns).SetValue(xiContacts.Current.SelectSingleNode("@Email").Value)
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='Changed']", ns).SetValue("false")
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='ID']", ns).SetValue(xiContacts.Current.SelectSingleNode("@ID").Value)
' Set the value of the Cmd attribute to "Update".
xnCAML.SelectSingleNode("/Batch/Method/@Cmd", ns).SetValue("Update")
' Submit the updates for the current row.
wsSubmit.Execute()
End If
' If the Delete field is set to "true" for the current
' row, in the Batch fragment set the ID for the row
' and set the Cmd attribute to "Delete".
If xiContacts.Current.SelectSingleNode("@Delete", ns).Value = "true" Then
xnCAML.SelectSingleNode("/Batch/Method/Field[@Name='ID']", ns).SetValue(xiContacts.Current.SelectSingleNode("@ID").Value)
xnCAML.SelectSingleNode("/Batch/Method/@Cmd", ns).SetValue("Delete")
' Submit the delete operation for the current row.
wsSubmit.Execute()
End If
End While
End If
' Create a DataConnection object for the MyContacts
' data connection.
Dim dcContacts As DataConnection = Me.DataConnections("MyContacts")
' Execute the data connection to refresh the list of
' contacts to reflect any additions, updates, or deletions.
dcContacts.Execute()
' Clear the values in the repeating table for
' adding new contracts.
ClearEnteredValues(xnDoc)
Catch ex As Exception
MessageBox.Show("The following error occurred: " + ex.Message)
Throw
End Try
Yes, domain. Thanks so much