<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Get Drop Down Display text by code</title><link>https://www.infopathdev.com:443/forums/thread/42346.aspx</link><pubDate>Mon, 01 Jun 2009 06:14:07 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:42346</guid><dc:creator>swathip</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/42346.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=42346</wfw:commentRss><description>Hi, 
&lt;p&gt;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 &lt;/p&gt;
&lt;p&gt;&amp;lt;RootNode&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;Value&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;ID&amp;gt;1&amp;lt;/ID&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;ListA&amp;gt;a1&amp;lt;/ListA&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;ListB&amp;gt;b1&amp;lt;/ListB&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/Value&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;Value&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;ID&amp;gt;2&amp;lt;/ID&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;ListA&amp;gt;a2&amp;lt;/ListA&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;ListB&amp;gt;b2&amp;lt;/ListB&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/Value&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;Value&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;ID&amp;gt;3&amp;lt;/ID&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;ListA&amp;gt;a3&amp;lt;/ListA&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;ListB&amp;gt;b3&amp;lt;/ListB&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/Value&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/RootNode&amp;gt;&lt;/p&gt;
&lt;p&gt;And your drop down ID value is ID (in the above xml), display name is ListA.&lt;/p&gt;
&lt;p&gt;1. Get this secondary xml in the code.&lt;/p&gt;
&lt;p&gt;IXMLDOMDocument2 listDOM = thisXDocument.GetDOM();&lt;/p&gt;
&lt;p&gt;2. Use SelectSingleNode and an XPath expression to find the one record that&lt;br /&gt;contains the selected value; use an XPath filter for this.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;a. Get the drop down value. i.e., id value &lt;/p&gt;
&lt;p&gt;&amp;nbsp;String idValue = thisXDocument.DOM.selectSingleNode(&amp;quot;Xpath of drop down&amp;quot;).text;&lt;/p&gt;
&lt;p&gt;3. Modify the XPath expression to include the node that corresponds to the text of the selected value, and retrieve&lt;/p&gt;
&lt;p&gt;String displayName = listDOM. selectSingleNode(string.Format(&amp;quot;RootNode/Value[ID = ‘{0}&amp;#39;]/ListA&amp;quot;, idValue))&lt;/p&gt;</description></item><item><title>Get Drop Down Display text by code</title><link>https://www.infopathdev.com:443/forums/thread/42199.aspx</link><pubDate>Thu, 28 May 2009 10:16:37 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:42199</guid><dc:creator>norale</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/42199.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=42199</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;I found this solution on how to get display text on a drop down by code, but i don&amp;#39;t understand how to do this. Could anyone translate this solution in a meaningful way? Your help is really appreciated. Thanks. :)&lt;/p&gt;&lt;p&gt;Getting Drop down display text:&lt;/p&gt;&lt;pre class="FreeTextFull"&gt;Use an XPath expression that contains a filter on the value that was selected&lt;br /&gt;from the drop-down list box and use this to retrieve the corresponding text&lt;br /&gt;by doing a lookup in the secondary data source that the drop-down is bound&lt;br /&gt;to. So:&lt;br /&gt;1. Retrieve the secondary data source that the drop-down is bound to in code.&lt;br /&gt;2. Use SelectSingleNode and an XPath expression to find the one record that&lt;br /&gt;contains the selected value; use an XPath filter for this.&lt;br /&gt;3. Modify the XPath expression to include the node that corresponds to the text of the selected value, and retrieve its value.&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>