Although Infopath designer can create most (much ?) of the User Interface, there can be times when it doesnt quite do what you need.
As an example, for drop down lists, you can pull in the values from an external data source
The dialog show the external connection and the value / display name as shown below
But what if you wanted to display both the id AND display name? The solution here is to drop into the XSL. Infopath uses XSL extensively & we can edit it if needed (Caution though, it is not as straight-forward as the normal editor & requires knowledge of XSLT). Note that the Infopath project must be saved as source files (if using Infopath.exe) or to access it in Visual Studio, close the manifest.xsf file.
By default, you will have View1.xsl - the xsl for the main view. Opening it will reveal something similar to that below, the xsl to display the drop down list and options
<select class="xdComboBox xdBehavior_Select" title="" style="WIDTH: 130px" size="1" xd:binding="my:TextNode" xd:boundProp="value" value="" xd:xctname="dropdown" xd:CtrlId="CTRL1" tabIndex="0">
<xsl:attribute name="value">
<xsl:value-of select="my:TextNode"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="function-available('xdXDocument:GetDOM')">
<option/>
<xsl:variable name="val" select="my:TextNode"/>
<xsl:if test="not(xdXDocument:GetDOM("CISF_DIVISION")/dfs:myFields/dfs:dataFields/d:CISF_DIVISION[@division_id=$val] or $val='')">
<option selected="selected">
<xsl:attribute name="value">
<xsl:value-of select="$val"/>
</xsl:attribute>
<xsl:value-of select="$val"/>
</option>
</xsl:if>
<xsl:for-each select="xdXDocument:GetDOM("CISF_DIVISION")/dfs:myFields/dfs:dataFields/d:CISF_DIVISION">
<option>
<xsl:attribute name="value">
<xsl:value-of select="@division_id"/>
</xsl:attribute>
<xsl:if test="$val=@division_id">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="@division"/>
</option>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<option>
<xsl:value-of select="my:TextNode"/>
</option>
</xsl:otherwise>
</xsl:choose>
</select>
The part we are interested in is the <option></option> values...
<option>
<xsl:attribute name="value">
<xsl:value-of select="@division_id"/>
</xsl:attribute>
<xsl:if test="$val=@division_id">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="@division"/>
</option>
By changing this to the code below, we can show both the id and name values...
<option>
<xsl:attribute name="value">
<xsl:value-of select="@division_id"/>
</xsl:attribute>
<xsl:if test="$val=@division_id">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="@division_id"/>
<xsl:text> : </xsl:text>
<xsl:value-of select="@division"/>
</option>
This will give us the following result
UPDATE
The example above was intended for Infopaht Client. AFIK the technique 'should' work for Forms server, but a quick test based upon a comment shows that the XSL may not render correctly