Hi!
I'm adding in an browser-enabled InfoPath Form dynamically with C# items, which works correctly.
I setted the DropDown Source to Fields of the Form ( MainSource ). Via C# OnLoad() event i add my items dynaicaly:
//-- set value of dropdown item
tempNode.SelectSingleNode("my:" + XPathField + "Value", IPForm.NamespaceManager).SetValue(searchResult[i][valueField].ToString());
textBuilder = new StringBuilder();
//-- create text of dropdown item by creating multi-column text values, splited by "|"
for(int k = 0; k < textFields.Length; k++) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// THIS CREATES THE TEXT VALUE, WHICH GETS DISPLAY, DYNAMICALY. EXAMPLE VALUE: 1 | blabla | ASDF
{
fieldValue = searchResult[i][textFields[k]].ToString();
toAdd = maxLength[k] - fieldValue.Length;
fieldValue += string.Join("", (string[])ArrayList.Repeat(" ", toAdd).ToArray(typeof(string))); ////////////////////////////////////////////////////// THIS JUST ADDS &NBSP; TO THE VALUES END, SO IT MACHTES THE SAME LENGTH AS ALL OTHER FIELDS
//fieldValue = fieldValue.PadRight(maxLength[k], ' '); //-- verify the text values have all the same size so the layout is ok
textBuilder.AppendFormat(" {0} |", fieldValue);
}
//-- get final text value string
fieldValue = textBuilder.ToString();
fieldValue = fieldValue.Substring(0, fieldValue.Length - 1).Trim();
//-- set text value
tempNode.SelectSingleNode("my:" + XPathField + "Text", IPForm.NamespaceManager).SetValue(fieldValue);
//-- add new dropdownlist-item to the field
mainGroup.AppendChild(tempNode);
My Problem is now, that InfoPath encodes the setted Text Value. The outputted JavaScript Code with the values shows ( InfoPath HTML encodes the value to &nbsp;) :
["","","1250","1250 | BLABLA&nbsp;&nbsp; | 1","1296","1296 | asdf&nbsp;&nbsp;&nbsp;&nbsp; | 1","1294","1294 | asdfasf&nbsp;&nbsp;&nbsp; | 1"]
Does Anybode know how to awoid this?
Thanks!