Drop-Down List Box : option/value pair - InfoPath Dev
in

InfoPath Dev

Drop-Down List Box : option/value pair

Last post 03-11-2005 09:11 AM by Agni Jonnalagadda. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-10-2005 03:10 PM

    Drop-Down List Box : option/value pair

    Hi All,

    I'm stumbling over something quite simple in other programming environments. My question is this: How can I obtain the 'option' in an option/value pair in an InfoPath Drop-Down List Box I call ddlPropertyName?

    I know how to get the 'value' for my PropertyNumber text box like so:

    Dim nodePropertyName As IXMLDOMNode
    nodePropertyName = thisXDocument.DOM.selectSingleNode("/my:myFields/my:grpPropertyName/my:ddlPropertyName")

    If Not nodePropertyName Is Nothing Then
    thisXDocument.DOM.selectSingleNode ("/my:myFields/my:txtPropertyNumber").text = nodePropertyName.text
    End If


    Now, how do I get the displayed 'option'?

    thisXDocument.DOM.selectSingleNode("/my:myFields/my:txtProperty").text = nodePropertyName.????

    Thanks in advance,

    Arnold
  • 03-11-2005 09:11 AM In reply to

    Re: Drop-Down List Box : option/value pair

    Getting the Option data if you give values directly to the dropdown is not possible as far as i know. But here is one workaround for your

    problem. Create an xml file in the following manner

    <SelectOptions>
    <Select option = "Option1" value = "value1"></Select>
    <Select option = "Option2" value = "value2"></Select>
    </SelectOptions>

    1. Add this file as a resource file via Tools -> resource files.
    2. Then create a data connection to this resource file via Tools -> Data connections.
    3. Double click on the dropdown in the view and choose the third option for the listbox entries, choose the data connection that

    you just created and set the value and display names correctly. Now the following code should work to get the display name.

    //First read the value into a string
    IXMLDOMNode nodePropertyName = thisXDocument.DOM.selectSingleNode("/my:myFields/my:grpPropertyName/my:ddlPropertyName")

    string value = null;

    If (null != nodePropertyName)
    value = thisXDocument.DOM.selectSingleNode ("/my:myFields/my:txtPropertyNumber").text = nodePropertyName.text

    else
    return;

    //Now to get the "Option" first get the newXmlFile. ConnectionName is the name that you give while creating the data connection.
    IXMLDOMDocument2 xmlDoc= (IXMLDOMDocument2)thisXDocument.GetDOM("ConnectionName");

    //Xpath of option in the XML file
    string optionXPath = string.format("/SelectOptions/Select[@value = '{0}']/@option", value);

    //read the option from xmlfile
    string Option = xmlDoc.selectSingleNode(optionXPath).text;


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