Query
You have a drop-down list box in InfoPath, which is bound to a SharePoint list that contains Product and Product_Id. The values of items in the drop-down list box and display names are bound to the Product_Id.
You want to be able to Fetch Values into Repeating Table on the basis of dropdown selected item in InfoPath
Solution
Use C# or Visual Basic code to loop through the rows and items in a repeating table.
Discussion
You can accomplish this functionality as follows:
1. In SharePoint, ensure that you have a SharePoint list that you can use. This list must contain Product and Product_Id. The SharePoint list should resemble Figure 1.
Figure 1. The SharePoint list.
2. In InfoPath, add a Data Connection to the SharePoint list. Ensure you select the Product, Product_Id fields from the SharePoint list when creating the data connection.
3. Add a Drop-Down List Box control to the InfoPath form template and bind it to the data connection for the SharePoint list. Set the @PRODUCT_ID of the SharePoint List to be the Value and the Display name of an item in the drop-down list box. And make sure that “show only entries with unique display names” should be check.
4. Add a Repeating Table control with 1 column to the InfoPath form template. Name the field in the column Product. The form template should resemble Figure 2.
Figure 2. The InfoPath form template in Design mode.
5. Double-click the Repeating Table control to open its Properties dialog box.
6. On the Repeating Table Properties dialog box, deselect checkbox”Show insert button and hint text”.
7. Now right click on the Drop-Down List Box control, click Programming and then click on “changed event”.
8. Add SharePoint References to the project.
9. Add the following C# code to the Changed event handler of the Drop-Down List Box control:
10. Save your work, build the project, and test the form template



No comments:
Post a Comment