Hello.
I have created an InfoPath form that has 4 dropdowns on it. 3 of the dropdowns (Location, Area and Type) allow me to query a SharePoint List and create an SPListItemCollection that contains Questions from the List. The 3 dropdowns filter the 4th dropdown which contains questions.
This part works fine but I want to populate the SPListItemCollection values from the List into the 4th dropdown on the InfoPath form.
In my code as follows the PopulateQuestions generates the list of questions from a CAML query in that function. This works correctly and returns my list items based on the items selected in the Location, Area and Type dropdowns.
The code fails with an error "Schema validation found non-data type" error but this is a Dropdown List on the form that I am trying to populate with a data type of string.
What is the correct way to populate the dropdown programmatically from an SPListItemCollection?
Here is my code:
try
{
//CALL THE FUNCTION TO POPULATE THE QUESTIONS OBJECT
SPListItemCollection questions = PopulateQuestions(nodeLocation.Value.ToString(), nodeArea.Value.ToString(), nodeType.Value.ToString());
//FILL THE QUESTIONS DROPDOWN WITH THE DATA RETURNED
if (questions != null)
{
foreach (SPListItem ListItem in questions)
{
nodeQClone = nodetQuestionList.Clone();
nodeQClone.SelectSingleNode("/my:dc/my:dcquestion", NamespaceManager ).SetValue(Convert.ToString(ListItem["Title"]));
//CODE FAILS AT NEXT LINE
nodeAuditQuestionList.InsertAfter(nodeQClone);
if (questions.Count > 0)
//DELETE THE PARENT NODE TO REMOVE DUPLICATE ENTRY
nodetQuestionList.DeleteSelf();
}
}
}
catch (Exception ex)
{
}