[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

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/">
  <description>(T) ED Inspection, LH</description>
- <Next>
  <description>(T) ED Inspection, RH</description>
- <Next>
  <description>(T) ED Offline Repair</description>
  • 2
1 Solution
Rose BabuSenior Team ManagerCommented:
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();

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

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

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

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

Open in new window

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

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now