Populate Drop Down List Programatically - Solved - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Populate Drop Down List Programatically - Solved

Last post 12-23-2004 03:22 PM by sasquatch. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-17-2004 07:20 AM

    Populate Drop Down List Programatically - Solved

    On the InfoPath newsgroup, Carole had asked Is there a way to programmatically bind a drop down list box, or do I have to use a web service as a secondary data source?" And Greg Collins response was populate a repeating list of nodes with individual values for each user...

    See the original thread here http://groups.google.com/groups?hl=en&lr=&frame=right&th=d8769aa5310fb641&seekm=evzfRvtuEHA.1524%40TK2MSFTNGP09.phx.gbl#link1

    I want to do something very similar. When the form is opened to be filled out, it automatically gets a list of name/id pair values of customers in a drop down list (field1). When the user selects a customer, I call a web service in the OnAfterChange event of field1, passing in the value of the selected customer name. In the web service, using the customer id, I get a list of order numbers into a DataSet object. How do I add the results in a DataSet object to a second drop down list (field2)?

    Hope this site gets lots of users. This could become a great community.

    Thanks.
  • 11-18-2004 06:17 AM In reply to

    Re: Populate Drop Down List Programatically - Solved

    I figured it out. Sort of...

    Here is how you do it...

    Layout of Controls:
    Drop down list box 1 (field1) button1 (btnGetCustomers)
    Drop down list box 2 (field2) button2 (btnGetOrders)

    Create a secondary data source. Go through the wizard, select the URL for the web service, select the web method you want to use, give it a friendly name (GetCustomersID) and deselect "Automatically retrieve data when form is opened." Click Finish.

    In C#:

    [InfoPathEventHandler(MatchPath="btnGetCustomers", EventType=InfoPathEventType.OnClick)]
    public void btnGetCustomers_OnClick(DocActionEvent e)
    {
    // Write your code here.
    WebServiceAdapterObject adapter = null;
    adapter = (WebServiceAdapterObject) thisXDocument.DataObjects["GetCustomersID"].QueryAdapter;
    adapter.Query();
    }


    Problem I have is (i'll create a seperate thread for this) is that the call to the second web service method requires an input parameter. I get an error "Reference to undeclared namespace prefix: 'dfs'" when I try to get the node that contains the input parameter.
  • 12-23-2004 03:22 PM In reply to

    Re: Populate Drop Down List Programatically - Solved

    The code below describe how to query and read the result of a
    webervice(Datasource) with Infopath

    //Request information from the webservice
    DataObject
    doConnection=thisXDocument.DataObjects["DataConnectionName"];

    //Fill parameter
    doConnection.DOM.selectSingleNode("//*[local-name()='param1']").text =
    param1;

    //Send the query
    doGroup.Query();
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.