Hi,
I have a browser form which receives data from a sharepoint list. I am copying that data into a repeating table in the main ds. I need it copied into a total of 3 repeating tables (identical tables), and can't seem to do it.
This is from a tutorial. I tried just making copies of the code with the correct names of the other tables, but an exception is thrown on this line: doc.AppendChild(group); that says there is already a document element.
My additional tables are (2 columns/2 fields):
/my:COBInquiry/my:group3/my:group4/my:field3
/my:COBInquiry/my:group3/my:group4/my:field4
/my:COBInquiry/my:group5/my:group6/my:field5
/my:COBInquiry/my:group5/my:group6/my:field6
Repeating table structure should end up being (this is simply InnerXml):
AACSB
AACSB
AACSB
AACSB
AACSB
AACSB
Here is my code:
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
XPathNavigator secDSNav = DataSources["ReferredBy"].CreateNavigator();
// Retrieve the rows of the secondary data source
// /dfs:myFields/dfs:dataFields/dfs:COBInquiryDataSource
XPathNodeIterator rows = secDSNav.Select("/dfs:myFields/dfs:dataFields/dfs:COBInquiryDataSource", NamespaceManager);
// Loop through the rows of the secondary data source and fill the repeating table
while (rows.MoveNext())
{
string title = rows.Current.SelectSingleNode("@Title", NamespaceManager).Value;
string displayname = rows.Current.SelectSingleNode("@DisplayName", NamespaceManager).Value;
// Add the item to the repeating table
AddItem(title, displayname);
}
// Remove the first empty item from the repeating table
DeleteFirstEmptyItem();
}
private void AddItem(string title, string displayname)
{
XmlDocument doc = new XmlDocument();
XmlNode group = doc.CreateElement("group2", NamespaceManager.LookupNamespace("my"));
XmlNode field = doc.CreateElement("field1", NamespaceManager.LookupNamespace("my"));
XmlNode node = group.AppendChild(field);
node.InnerText = title;
field = doc.CreateElement("field2", NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText = displayname;
doc.AppendChild(group);
MainDataSource.CreateNavigator().SelectSingleNode("/my:COBInquiry/my:group1", NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());
}
The end result I want is all the data in the splist split among all three tables...So if the splist has 32 entries, 10 would be in one table, 11 in another, and 11 in the last. If anyone also knows how to do this, programmatically in code, I would appreciate it a lot!