Populating a dropdown list - InfoPath Dev
in

InfoPath Dev

Populating a dropdown list

Last post 04-21-2010 04:05 AM by alexia_net. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 04-20-2010 03:23 AM

    Populating a dropdown list

    Hi. I need to add some values in a dropdownlist using a customised code. What is the command for doing so.  I have tried to find .Item or to use .Insert but it did not help.

    If this is the item on the form

    xnFormName = xnDoc.CreateNavigator.SelectSingleNode("/my:AddRoom/my:ddlFloor", Me.NamespaceManager)

    How do i add values into it? Thank you!

  • 04-20-2010 04:56 AM In reply to

    Re: Populating a dropdown list

    you will need to bind your dropdown to some repeating table, and add value to the repeating table through code.

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 04-20-2010 05:05 AM In reply to

    Re: Populating a dropdown list

     Hi. Thank you for your answer. I do not get it. Why? Isnt just like an ordinary textbox except that it is a collection of items? Is not possible to just use somenting like .additem("da") or something similar? Imagine that i have a textbox a dropdownbox and a button. If i type "ONE" in the textbox, when I push the button I want the value "ONE" to be added into the DropDownBox, and so on. Must I bind it to a repeating table in this case? Thank you!

  • 04-20-2010 05:21 AM In reply to

    Re: Populating a dropdown list

     Anyone? I realy need this. Thank you!

  • 04-20-2010 06:50 AM In reply to

    Re: Populating a dropdown list

    Qazi Anis is correct.  InfoPath controls do not work like WinForm or ASP.NET controls.  You cannot access them directly from code.  If you want to modify the set of items a Dropdown list contains, you must bind it to a node in one of your data sources and modify that node.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-20-2010 06:51 AM In reply to

    Re: Populating a dropdown list

     I am trying to do this using this code:

                 Dim i As Integer
                Dim newValue As String

                Dim Loc As XPathNavigator
                Dim templateNode As XPathNavigator
                Dim newNode As XPathNavigator

                Loc = Me.MainDataSource.CreateNavigator()
                Loc.SelectSingleNode("/my:AddRoom/my:ddlFloor", Me.NamespaceManager)
                Loc.SetValue("")
                templateNode = Loc.Clone()
                newNode = templateNode.Clone()

                For i = 1 To 2
                    newValue = Convert.ToString(i)
                    newNode.SetValue(newValue)
                    Loc.InsertAfter(newNode)
                Next

    I get this error:

    Operation is not valid due to the current position of the navigator.

    What does this mean exactly? Is it out of range or something? Thank you!

  • 04-20-2010 06:58 AM In reply to

    Re: Populating a dropdown list

     Hi. I am new with InfoPath and I have no idea how to start writing the code. I have binded the DDL to that table, but I do not know how to proceed further. Any tips? Thx.

  • 04-21-2010 01:16 AM In reply to

    Re: Populating a dropdown list

     Hi. I have changed the code and I am using this:

                 rptTblNAV = Me.MainDataSource.CreateNavigator()
                rptTblNAV.SelectSingleNode("/my:AddRoom/my:rtbFloorsInUseGr1", Me.NamespaceManager)

                Gr1Nav = rptTblNAV.SelectSingleNode("/my:AddRoom/my:rtbFloorsInUseGr1/my:rtbFloorsInUseGr2", Me.NamespaceManager)
                'Gr1Nav = rptTblNAV.Clone()
                Gr2Nav = rptTblNAV.SelectSingleNode("/my:AddRoom/my:rtbFloorsInUseGr1/my:rtbFloorsInUseGr2/my:field0", Me.NamespaceManager)
                newValue = Gr2Nav.Clone()

                newValue.SelectSingleNode("value").SetValue("bla")
                newValue.SelectSingleNode("displayname").SetValue("bla1")
                Gr1Nav.AppendChild(newValue)

     But at line

    Gr1Nav.AppendChild(newValue)

    i get this error:

    Schema validation found non-data type errors

    Can someone help pls? Thank you!

  • 04-21-2010 04:05 AM In reply to

    Re: Populating a dropdown list

     If anyone wants the solution, its here

    http://blog.naver.com/lightyea/100098254555

    Have fun.

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