how to link a listbox with a dataset

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
 
J

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,
 
E

Edd Connolly

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top