Infopath 2010 form binding data to dropdownlist from web service

A short code snippet to get the data from the web service and binding to dropdownlist.

First of all create a web service that returns a data set ,create a dataconnection from infopath that retrieves data from web service and binding data source to drop down list.


1) Creating web service

public DataSet RegCust()
string returnstr = “Insert failed”;
SqlConnection dbConn = new SqlConnection(“database=ims;server=;uid=sa;password=@System”);
string sqlstr = “select productid,productname,unitprice,numofitems,TotalAmount from tblorderdetails”;
SqlCommand dbComm = new SqlCommand(sqlstr, dbConn);
SqlDataAdapter da = new SqlDataAdapter(dbComm);
ds = new DataSet();
if (ds.Tables[0].Rows.Count != 0)
returnstr = “Insert succeeded”;
returnstr = “Insert succeeded”;
catch (Exception e)
return ds;

Debug this and copy the URL:http://localhost:1983/getCompanyName.asmx


2)Create dataconnection to retrive data from web service using infopath 

Steps:1) Click on “Data-Data Connections” from top ribbon


2)Add a new connection from the DataConnections wizard


3) Select operation Retrive 


4)Select a source type,since it is a web service..we select first option


5)Get the web servie details using the URL Copied from the above stepImage

7)Select the method that returns datasetImage

8)Clcik next and next


Binding Data Source to DropDownList

1)Right click on the drop down list and select “drop down list properties” and select “Get choices from the external data sources”



2)Select the field that you want to display in the drop down list as follows


3)Preview to see the output


About alekhyakodamsharepoint

Hi.. I am alekhya working as a sharepoint developer.
This entry was posted in Infopath 2010. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s