We help IT Professionals succeed at work.

ComboBox DataBinding

I am trying to return data from a web service looks like below.  I can call the service and get data back, it comes back as a type StationInfo.  

I need to bind this to a ComboBox?




Calling the WS:
 object CISStations = getCISStations.GetCISStations(strProc);



From Web Service Interface:
<?xml version="1.0" encoding="utf-8" ?>
- <CISReturntype xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
  <value>44</value>
  <description>(T) ED Inspection, LH</description>
- <Next>
  <value>43</value>
  <description>(T) ED Inspection, RH</description>
- <Next>
  <value>52</value>
  <description>(T) ED Offline Repair</description>
Comment
Watch Question

Rose BabuSenior Team Manager

Commented:
Hi, Do you know what is the return type of GetCISStations method?

you can iterate the CISStations and add the values to the datatable (e.g., in dtCombo)

after that assign this datatable as a datasource to the combobox. and set the datatextfield, datavaluefield then bind it.
 below is the sample bind process with sample data.
 
// Sample Data
DataTable dtCombo = new DataTable();
dtCombo.Columns.Add("Value");
dtCombo.Columns.Add("Description");

DataRow drCombo;
drCombo = dtCombo.NewRow();
drCombo["Value"] = "44";
drCombo["Description"] = "(T) ED Inspection, LH";
dtCombo.Rows.Add(drCombo);

drCombo = dtCombo.NewRow();
drCombo["Value"] = "43";
drCombo["Description"] = "(T) ED Inspection, RH";
dtCombo.Rows.Add(drCombo);

drCombo = dtCombo.NewRow();
drCombo["Value"] = "52";
drCombo["Description"] = "(T) ED Offline Repair";
dtCombo.Rows.Add(drCombo);
// Sample Data

// Bind Data to ComboBox
ddlEETest123.DataSource = dtCombo;
ddlEETest123.DataTextField = "Description";
ddlEETest123.DataValueField = "Value";
ddlEETest123.DataBind();

Open in new window

Author

Commented:
I don't know what that return type is from the web service.  That is part of the problem.
Senior Team Manager
Commented:
do you have the wsdl link or file? if so pls post that

Explore More ContentExplore courses, solutions, and other research materials related to this topic.