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

x
  • 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/">
  <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>
0
triplebd69
Asked:
triplebd69
  • 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();
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

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

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