how to link a listbox with a dataset

  • Thread starter Thread starter Jake
  • Start date Start date
J

Jake

Hello,

I have a web page that has a listbox. I want to populate the listbox
based upon the dataset that is returned from a webservice. The data set
returns two columns of data. The first column is the ID and the second
column is the VALUE. How can I populate the list box with the VALUE and if
clicked use the ID? Thanks in advance.

Jake
 
Edd,

Thanks that worked.

Jake

Edd Connolly said:
Jake,

Set the DataSource of the ListBox to be the DataSet.
Set the DataTextField to be "VALUE" (or whatever the column is called in the
DataSet).
Set the DataValueField to be "ID" (or whatever the column is called in the
DataSet).
Ensure DataBind() is called on the ListBox.
You can then access the current ID in the SelectedIndexChanged event handler
(for example) of the ListBox via the SelectedValue property.

Hope this helps,
 
Jake,

Set the DataSource of the ListBox to be the DataSet.
Set the DataTextField to be "VALUE" (or whatever the column is called in the
DataSet).
Set the DataValueField to be "ID" (or whatever the column is called in the
DataSet).
Ensure DataBind() is called on the ListBox.
You can then access the current ID in the SelectedIndexChanged event handler
(for example) of the ListBox via the SelectedValue property.

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top