Get Drop Down Display text by code - InfoPath Dev
in

InfoPath Dev

Get Drop Down Display text by code

Last post 05-31-2009 11:14 PM by swathip. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-28-2009 03:16 AM

    Get Drop Down Display text by code

    Hi,

    I found this solution on how to get display text on a drop down by code, but i don't understand how to do this. Could anyone translate this solution in a meaningful way? Your help is really appreciated. Thanks. :)

    Getting Drop down display text:

    Use an XPath expression that contains a filter on the value that was selected
    from the drop-down list box and use this to retrieve the corresponding text
    by doing a lookup in the secondary data source that the drop-down is bound
    to. So:
    1. Retrieve the secondary data source that the drop-down is bound to in code.
    2. Use SelectSingleNode and an XPath expression to find the one record that
    contains the selected value; use an XPath filter for this.
    3. Modify the XPath expression to include the node that corresponds to the text of the selected value, and retrieve its value.

     

  • 05-31-2009 11:14 PM In reply to

    Re: Get Drop Down Display text by code

    Hi,

    First thing you need to get the values from the secondary data connection in to drop down. For example your secondary xml (list.xml) may contain like

    <RootNode>

    <Value>

    <ID>1</ID>

    <ListA>a1</ListA>

    <ListB>b1</ListB>

    </Value>

    <Value>

    <ID>2</ID>

    <ListA>a2</ListA>

    <ListB>b2</ListB>

    </Value>

    <Value>

    <ID>3</ID>

    <ListA>a3</ListA>

    <ListB>b3</ListB>

    </Value>

    </RootNode>

    And your drop down ID value is ID (in the above xml), display name is ListA.

    1. Get this secondary xml in the code.

    IXMLDOMDocument2 listDOM = thisXDocument.GetDOM();

    2. Use SelectSingleNode and an XPath expression to find the one record that
    contains the selected value; use an XPath filter for this.

     a. Get the drop down value. i.e., id value

     String idValue = thisXDocument.DOM.selectSingleNode("Xpath of drop down").text;

    3. Modify the XPath expression to include the node that corresponds to the text of the selected value, and retrieve

    String displayName = listDOM. selectSingleNode(string.Format("RootNode/Value[ID = ‘{0}']/ListA", idValue))

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