473,503 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to link a listbox with a dataset

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
Nov 18 '05 #1
2 1438
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,
--
Edd Connolly

MCP 70-315


"Jake" <ro******@hotmail.com> wrote in message
news:uk**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2
Edd,

Thanks that worked.

Jake

"Edd Connolly" <ed******************@hotmail.com> wrote in message
news:MG****************@newsfe3-gui.ntli.net...
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,
--
Edd Connolly

MCP 70-315


"Jake" <ro******@hotmail.com> wrote in message
news:uk**************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2105
by: mathieu cupryk | last post by:
I have problems with listboxes in the webform2.cs, the textboxes are working well when I do a click on next. I am missing something. It works with the textboxes. Here is the file: using System;...
2
1444
by: Gordon | last post by:
Hi; I am a novice asp.net developer who would like to create a dataset-table and then use the datatable.select cmd. to look up a value passed from the web calender control. The value(s) would...
6
2858
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
5
4396
by: Dave | last post by:
Hi All, I have a windows form that contains 2 listboxes and 2 buttons. The listbox on the right is populated by a database routine (This is the easy part). The listbox on the left is populated...
1
3033
by: Spock | last post by:
Hi. I have a form with a listbox and a few label fields all bound to a dataset. When i navigate the listbox the labels change accordingly. so far everything works good. I made a button to...
3
2822
by: Robert W. | last post by:
I have a SQL Server table called "ClosedMonths" that contains two pertinent fields: Yearx Monthx 2000 1 2000 2 2000 3 I want to simply query this...
2
3820
by: rrflore2 | last post by:
Ok. I'm writing and deleting to an xml file using a dataset. I have a function in my codebehind page that binds a listbox to the dataset that performs the writes/deletes. Everything seems to be...
1
1524
by: MariaKhan | last post by:
?? bind DataSet with listbox ??? ?? bind DataSet with listbox ??? ?? bind DataSet with listbox ??? ?? bind DataSet with listbox ??? ?? bind DataSet with listbox ???
1
2488
by: sweetiecakes | last post by:
Hi I have a ListBox which is binded to a dataSet. When I need to refresh this dataSet, it works, but the old entries don't get removed from the listbox. Items.Clear() doesn't work when a...
0
7342
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.