Hi everyone, I have an Infopath web form that goes out to to a DB and gets a Generic list of objects (a class called company). It then loops through that List<Company> and adds each one to a dropdown list box in code. It works really well, but in the infopath client or in the browser, if I pull more than 2500 records from the DB for the dropdownlist - it basically locks up. I actually need to be able to pull 12,000. I don't want to setup a dataconnection and bind the dropdown listbox to that, because I get slow script problems in IE.
does anyoen have issues with adding a lot of items to drop down listboxes?
this is my code:
// my loop through each company in the list.
foreach (Company c in CompanyList)
{
// method to add to the dropdown list
UpdateDropDownList("/my:myFields/my:Container/my:CompanyListGroup", "CompanyListItem", "CompanyListItemName", "CompanyListItemValue", c.CompanyName, c.CompanyId.ToString());
}
private void UpdateDropDownList(string repeatingItemGroup, string repeatingItem, string repeatingItemName, string repeatingItemValue, string name, string value)
{
try
{
XPathNavigator root = MainDataSource.CreateNavigator();
XmlDocument doc = new XmlDocument();
XmlNode group = doc.CreateElement(repeatingItem, NamespaceManager.LookupNamespace("my"));
XmlNode field = doc.CreateElement(repeatingItemName, NamespaceManager.LookupNamespace("my"));
XmlNode node = group.AppendChild(field);
node.InnerText = name; // set the display field
field = doc.CreateElement(repeatingItemValue, NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText = value; // set the underlying value
doc.AppendChild(group);
// binding to the xml doc
MainDataSource.CreateNavigator().SelectSingleNode(repeatingItemGroup, NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());
}
catch (Exception ex)
{
throw (ex);
}