I have a SharePoint I am trying to populate a repeating table in the form. I keep getting a Object reference not set to an instance of an object. on the Elements @Start_Postion, @End_Postion, @ Lenght.
I am not sure if I am doing something completely wrong or not.
here is the code i have so far.
XPathNavigator secDSNav = DataSources["File Layout Container"].CreateNavigator();
// Retrieve the rows of the secondary data sourceXPathNodeIterator rows = secDSNav.Select(
"/dfs:myFields/dfs:dataFields/dfs:File_Layout_Container", NamespaceManager);
// Loop through the rows of the secondary data source and fill the repating tablewhile (rows.MoveNext())
{
string FieldName = rows.Current.SelectSingleNode(
"@Field_Name", NamespaceManager).Value;string DataType = rows.Current.SelectSingleNode(
"@Data_Type", NamespaceManager).Value;string StartPosition = rows.Current.SelectSingleNode(
"@Start_Position", NamespaceManager).Value;string EndPosition = rows.Current.SelectSingleNode(
"@End_Position", NamespaceManager).Value;string Position = rows.Current.SelectSingleNode(
"@Positon", NamespaceManager).Value;string Length = rows.Current.SelectSingleNode(
"@Length", NamespaceManager).Value;
// Add the item to the repeating table
AddItem(FieldName, DataType, StartPosition, EndPosition, Position, Length);
}
// Remove the first empty item from the repeating table
DeleteFirstEmptyItem();
}
}
private void AddItem(string FieldName, string DataType, string StartPosition, string EndPosition, string Position, string Length)
{
XmlDocument doc = new XmlDocument();
XmlNode group = doc.CreateElement("Targeting_Iteration_Recurrence_File_Layout_Fields",NamespaceManager.LookupNamespace("my"));
XmlNode field = doc.CreateElement("Field_Name_Output_Target",NamespaceManager.LookupNamespace("my"));XmlNode node = group.AppendChild(field);
node.InnerText = FieldName;
field = doc.CreateElement(
"Data_Type_Output_Target",NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText = DataType;
field = doc.CreateElement("Start_Postion_Output_Target",NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText = StartPosition;
field = doc.CreateElement("End_Postion_Output_Target",NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText = EndPosition;
field = doc.CreateElement("Position",NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText = Position;
field = doc.CreateElement("Length_Output_Target",NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText = Length;
doc.AppendChild(group);
MainDataSource.CreateNavigator().SelectSingleNode(
"/my:myFields/my:Section_D_Target_Pop_Req/my:Sub-Section_D6_Output_File_Requirements/my:Preset_Frequency_GRP/my:Recurrence_Frequency/my:Preset_Frequency/my:Targeting_REQ/my:Targeting_Iteration_Recurrence_Additional_File_Layout_Fields",
NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());
}
Any help would be great!