fill drop down via code - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

fill drop down via code

Last post 07-26-2010 04:27 AM by IoannaGian. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-22-2009 07:08 AM

    • Gagan
    • Top 500 Contributor
    • Joined on 06-02-2009
    • Posts 31

    fill drop down via code

    hi all

    i have three drop downs, the use selects the product in the first one, and the 2nd one gets populated automatically via rules. the 2nd dropdown can only be one value. my problem is dropdown 3 the person needs to select the detection, but there are WAY too many, so it needs to be filtered depending on what is selected in dropdown2. i would ideally like to do it via code, because i tried a nested XML but cant seem to get it work.

           dropdown1          dropdown2                     dropdown3
           product1 --->       system one                  detection1 OR detection 2 OR detection 3
           product2--->        system one                  dectection 2 OR detection 5
           product3--->        system three               dectection 1


    Here is the code i have so far


    Public Sub Product_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)


    Dim root As XPathNavigator = MainDataSource.CreateNavigator()

    Dim product As String = root.SelectSingleNode("my:myFields/my:Product", NamespaceManager).InnerXml

    Dim detectiondevice As String = root.SelectSingleNode("my:myFields/my:DetectionDevice", NamespaceManager).InnerXml


    If product = "Product1" Then

    detectiondevice = new string("magnet,"lucky")

    End If

    End Sub


    The problem is my  new string is not the right expression to use, as it mistakes the "lucky" as an integer and not a text value.

  • 06-24-2009 11:14 PM In reply to

    Re: fill drop down via code


    You can do this using the following xml.


              <DDOne value="Product1">

                       <DDTwo value="system one"></DDTwo>

                       <DDThree value="detection1"></DDThree>

                       <DDThree value="detection2" ></DDThree>

                       <DDThree value="detection3"></DDThree>


              <DDOne value="Product2">

                       <DDTwo value="system one"></DDTwo>

                       <DDThree value="detection2" ></DDThree>

                       <DDThree value="detection5"></DDThree>       


              <DDOne value="Product3">

                       <DDTwo value="system three"></DDTwo>

                       <DDThree value="detection1"></DDThree>




    Name this xml as Test.xml.

    • 1. Take the receive data connection for this xml.
    • 2. Now to drop down 1 properties.
    • 3. Select ‘Look up values from an external data source' option. Select the above secondary xml as data source in data source drop down.
    • 4. Click on a button beside the Entries text box and select value under DDOne.
    • 5. Click ok.
    • 6. Now go to drop down 2 properties.
    • 7. Do the same as in step 3.
    • 8. Click on a button beside the Entries text box and select value under DDTwo and click Filter Data.
    • 9. Click Add button, select the value under DDONe in first drop down, is equal to in second drop down, drop down 1 (in mail source) in third drop down.
    • 10. Click ok until all the windows gets closed.
    • 11. Now go to drop down 3 properties.
    • 12. Do the same as in step3.
    • 13. Click on a button beside the Entries text box and select value under DDThree and click Filter Data.
    • 14. Do the same as in step 9.
    • 15. Click ok.
  • 07-26-2010 04:27 AM In reply to

    Re: fill drop down via code

    Hello everybody,

    I am new to this forum and a beginner at Infopath. I have a form in which people in my company can choose a week(for example Week 29 / 19Jul-25Jul ) from a drop down list, and then fill in the projects that they will accomplish during this week. In the form there is also a repeating table, which shows the history of the specific user (all the weeks and projects he has already inserted), as following:
    Week 30/ 26Jul-01Aug -> Project A
    Week 29/ 19Jul-25Jul -> Project B

    The weeks are extracted from an XML file. For the history table, I have made a secondary connection to the database.

    What I would like to happen, is, the drop down box to show only the weeks that are not already inserted, thus, the weeks that are not contained in the history table. I have tried the filter option but it doesn't seem to give me the right result. Any ideas on how I could make it through code? Or, alternatively, how I could save the repeating table data in an xml file? (the data in the repeating table comes from the database but it is filtered (by user) )

    Thanks in advance,

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.