simple drop down box get value error - InfoPath Dev
in

InfoPath Dev

simple drop down box get value error

Last post 10-05-2005 06:25 AM by Matt Faus. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 10-04-2005 02:33 PM

    • nkelkar
    • Not Ranked
    • Joined on 09-30-2005
    • Canada
    • Posts 11

    simple drop down box get value error

    Within infopath form I have fields that are stored on the SQL Datbase. No problem. Using this assistance http://weblogs.asp.net/jan/archive/2004/03/16/90533.aspx I have a dropdown list of all the users of a Site bound to "SubmittedBy". (this dropdown list is an XML file)

    Now I have done a simple "Test" button (using vb.net) to Alert who the currently selected user is. (I open the form, select a user from the drop down list and press "Test")

    Here's the code:

    <InfoPathEventHandler(MatchPath:="BTN_TEST", EventType:=InfoPathEventType.OnClick)> _
    Public Sub BTN_TEST_OnClick(ByVal e As DocActionEvent)
        ' Write your code here.
        Try
            Dim cVal = thisXDocument.DOM.selectSingleNode("//d:TrRevCostMain/SubmittedBy")
            If Not cVal Is Nothing Then
                thisXDocument.UI.Alert(cVal.text)
            Else
                thisXDocument.UI.Alert("Not Selected")
            End If
        Catch ex As Exception
                    thisXDocument.UI.Alert(ex.Message)
        End Try
    End Sub


    For the N'TH Time, it always alerts "Not Selected", no matter if I select a user in the dropdown list or not. So the condition (Not cVal Is Nothing) is ALWAYS TRUE, cVal is ALWAYS 'Nothing'

    I have tried to retreive other element values from the form, eg simple text boxes which are returned correctly.

    Any idea why? It seems so difficult to retrieve a simple value from a drop down list?

    This is driving me c.r.a.z.y

    Thanks.
  • 10-04-2005 02:43 PM In reply to

    Re: simple drop down box get value error

    :)

    Change
    Dim cVal = thisXDocument.DOM.selectSingleNode("//d:TrRevCostMain/SubmittedBy")


    To
    Dim cVal = thisXDocument.DOM.selectSingleNode("//d:TrRevCostMain/d:SubmittedBy")


    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 10-04-2005 03:27 PM In reply to

    • nkelkar
    • Not Ranked
    • Joined on 09-30-2005
    • Canada
    • Posts 11

    Re: simple drop down box get value error

    Sorry, not working either. I have tried all possible pathnames, with all kinds of .nodename .nodetype .nodetypedvalue .nodetypestring .nodevalue - all without any success.

    The thing thats cra**ing out is check for Nothing, it Always is True, ie, the cVal is Always Nothing. Very Very strange.

    When I simply alert other form text box directly, without checking for "Nothing" they are alerted correctly.

    If I try to retrieve other form text boxes through this code even they are getting "Nothing".

    So now I suspect setting the correct Namespace.

    Is this a bug, the dropdown list is a secondary source, have others been able to get a value of selected dropdown list, when it is a secondary source from xml file?

    Am I totally of track here?

    Thanks.
  • 10-04-2005 04:01 PM In reply to

    • nkelkar
    • Not Ranked
    • Joined on 09-30-2005
    • Canada
    • Posts 11

    Re: simple drop down box get value error

    I think I am ready to *** myself.

    In the database field was named as SubmitttedBy

    In my vbcode I was checking against SubmittedBy

    Notice a missing 't'

    Anyways here is the code thats working for me now

      <InfoPathEventHandler(MatchPath:="BTN_TEST", EventType:=InfoPathEventType.OnClick)> _
      Public Sub BTN_TEST_OnClick(ByVal e As DocActionEvent)
       ' Write your code here.
       Try
        Dim cNode As IXMLDOMNode = thisXDocument.DOM.selectSingleNode("//d:TrRevCostMain")
        Dim cVal = cNode.attributes.getNamedItem("SubmittedBy")
        If Not cVal Is Nothing Then
         thisXDocument.UI.Alert(cVal.text)
        End If
       Catch ex As Exception
        thisXDocument.UI.Alert(ex.Message)
       End Try
      End Sub

    Thanks
  • 10-05-2005 06:25 AM In reply to

    Re: simple drop down box get value error

    Ouch. At least you learned a lesson.

    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.