Reading the selected value of a dropdown box - InfoPath Dev
in

InfoPath Dev

Reading the selected value of a dropdown box

Last post 08-05-2011 08:11 AM by ProgramMax. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-05-2011 06:56 AM

    Reading the selected value of a dropdown box

    I have a browser form (InfoPath 2007 and MOSS2007) that contains a dropdown box. That box is bound to "Look up values in the form's data source" "/my:myFields/my:PayrollPeriods/my:Period" with value and display name both as "my:Combined".

    The Combined field is to contain information like "1 - 12/20/2010 - 12/2011".

    I'm filling this repeating group programmatically.

    I created a Changed event handler for the dropdown box so I can react to the user choosing a new option. I'm attempting to read the value but am running into a strange problem...I created a multi-line textbox to view what's happening. Here is the code I have:

    XPathNavigator MainNavigator = MainDataSource.CreateNavigator();
    XPathNavigator PayrollPeriodsElement = MainNavigator.SelectSingleNode("/my:myFields/my:PayrollPeriods", NamespaceManager); // this is the path to the actual dropdown list element
    XPathNavigator TestElement = MainNavigator.SelectSingleNode("/my:myFields/my:Test", NamespaceManager); // this is the multi-line textbox
    
    TestElement.SetValue(PayrollPeriodsElement.Value));

    The multi-line textbox is filled with EVERY value in the Payroll Periods dropdown box (appended into one long string). It isn't just the value that was selected.

    Any thoughts on what I'm doing wrong here?
    Thanks!

  • 08-05-2011 08:11 AM In reply to

    Re: Reading the selected value of a dropdown box

    Oh my goodness, I found the mistake. It was something silly.

    My PayrollPeriodsElement path should be .../my:PayrollPeriod (notice that is singular, not plural).
    The plural .../my:PayrollPeriods holds the actual list itself.

    Whoops :)

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