If somebody like the post and its helpful in your work then, add comments.

Wednesday, June 17, 2009

Populating Drop Down List Box in InfoPath 2007

Generally when we have to populate data in the drop down of InfoPath we generally follow the resource file way which is present at following link. But there is another way also for that work.

For that we have to follow below steps:

1. We have a list in SharePoint from which we have to fill data in drop down box.

2. Goto control in InfoPath drag a drop down list box in the form.

3. Goto data source in InfoPath add group in the datasource like as follows:

4. In this repeting group add the two Field Displayname and Value.

5. For Display name, from data source right click on Group, and click Add

6. Similarly follow 5th step again for “Value” field. The group looks like that

7. Then goto DropDown List Box propeties and opt the follwoing option :

8. Select the newly added repeting group in the xpath in the entries field. Also select display name and values from the repeting group.

9. Open the code/event where to write the code for populating the drop down.

10. Write the following code:

public void PopulateDropDown()




SPSite Rootsite = SPContext.Current.Site;

SPWeb website = Rootsite.OpenWeb();

SPList SharePointList = website.Lists["Customers"];

SPListItemCollection SharePointListItems = SharePointList.Items;

XPathNavigator XMLDom = this.CreateNavigator().SelectSingleNode("/my:myFields/my:Group", this.NamespaceManager);

foreach (SPListItem Item in SharePointListItems)


XPathNavigator NewCloneNode = null;

NewCloneNode = XMLDom.Clone();

NewCloneNode.SelectSingleNode("/my:myFields/my:Group/my:Displayname", this.NamespaceManager).SetValue(Item["AccountName"].ToString());

NewCloneNode.SelectSingleNode("/my:myFields/my:Group /my:Value", this.NamespaceManager).SetValue(Item["Desktops"].ToString());


NewCloneNode = null;



NewCloneNode = null;







1. Don’t have to delete again and again the filled nodes in the drop down.
2. Less code work (Smart Work).
3. Performance increase.


  1. Brilliat solution.... will definitely help improve the perfomance of the Bulky IP forms we use :)

  2. Smart and cool work buddy, it will help definately to developers!!!

  3. Hi,
    I have the same code to populate the repeating group and binding to a dropdown list.
    In this case, i have huge performance issue as the loop to set the value for "DisplayName" and "Value" takes more time.

    Can you please assist me ?


  4. Hi,

    It doesn't work when the DropDown List Box is in a Repeating Section. It just work for the first section, but not for the others sections.

  5. Hi, I found the solution, I had to create another group and it worked.
    So, it doesn't work when you create this group in the same repeating section, you have to create this group in other side.