<?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>General</title><link>https://www.infopathdev.com:443/forums/41.aspx</link><description>If you're not sure where to ask your question, ask it here. If necessary, our moderators will make sure it gets classified in the correct board.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: How to set default value in dropdown box by code.</title><link>https://www.infopathdev.com:443/forums/thread/51509.aspx</link><pubDate>Mon, 08 Feb 2010 14:41:02 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:51509</guid><dc:creator>gombear</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/51509.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=51509</wfw:commentRss><description>&lt;p&gt;Oh, my.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m must having senior moment.&amp;nbsp;&amp;nbsp; Thank a lot.&lt;/p&gt;</description></item><item><title>Re: How to set default value in dropdown box by code.</title><link>https://www.infopathdev.com:443/forums/thread/51471.aspx</link><pubDate>Sat, 06 Feb 2010 04:38:35 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:51471</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/51471.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=51471</wfw:commentRss><description>&lt;p&gt;You need to pass the NamespaceManager to SelectSingleNode().&amp;nbsp; You&amp;#39;re already doing that correctly in this line:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;XmlWriter&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; writer = MainDataSource.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;/my:myFields/my:SomeGroup&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).AppendChild();&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;</description></item><item><title>How to set default value in dropdown box by code.</title><link>https://www.infopathdev.com:443/forums/thread/51464.aspx</link><pubDate>Fri, 05 Feb 2010 21:25:05 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:51464</guid><dc:creator>gombear</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/51464.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=51464</wfw:commentRss><description>&lt;p&gt;I&amp;#39;m getting error/exception from setting default value for dropdown list.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Here is what I&amp;#39;m doing.......&lt;/p&gt;
&lt;p&gt;I have a dropdown box that is populated from repeating node values in the form.&lt;/p&gt;
&lt;p&gt;//***This is&amp;nbsp;to create values for the repeating node.&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; myNameSpace = NamespaceManager.LookupNamespace(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;my&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;try&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;{&lt;/font&gt;&lt;/p&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Action&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] xxCodes = &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DAO&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.GetValues(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;some&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;for&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; i = 0; i &amp;lt; xxCodes.Length; i++)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;XmlWriter&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; writer = MainDataSource.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;/my:myFields/my:SomeGroup&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).AppendChild();&lt;/p&gt;writer.WriteStartElement(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;SomeGroups&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, myNameSpace);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;writer.WriteElementString(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;someValue&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, myNameSpace, xxCodes[i].Code);&lt;/p&gt;writer.WriteElementString(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;someDisplayName&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, myNameSpace, xxCodes[i].Description);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;writer.WriteEndElement();&lt;/p&gt;
&lt;p&gt;writer.Close();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;......&lt;/p&gt;
&lt;p&gt;//Then I map the dropdown list box to this repeating node.&amp;nbsp; dropdown list works fine&lt;/p&gt;
&lt;p&gt;So far so good.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;//&lt;/p&gt;
&lt;p&gt;Now I want depend on the other value, I want to pre-select the value for this dropdown list.&amp;nbsp; So this pre-selected value will display as default value, but users can still change it by clicking dropdown selection button.&lt;/p&gt;
&lt;p&gt;//Here is a snippet of code to set default display.&amp;nbsp;&lt;/p&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;
&lt;p&gt;XPathNavigator&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; navigator = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;this&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;.CreateNavigator();&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;
&lt;p&gt;navigator.SelectSingleNode(&amp;quot;/my:myFields/my:dropdownlist&amp;quot;).Setvalue(&amp;quot;defaultValue&amp;quot;);&lt;/p&gt;
&lt;p&gt;//Then this line of code produce this exception&lt;/p&gt;
&lt;p&gt;&amp;gt;&lt;font color="red"&gt;System.Xml.XPath.XPathException: Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;How do I fix this?&amp;nbsp; Or What is the proper code to set default value for dropdown list?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;</description></item></channel></rss>