?
Solved

EASY - Bind a list box to a dataset - how to

Posted on 2006-03-28
2
Medium Priority
?
150 Views
Last Modified: 2010-05-01
Hello All,

Does anyone know how to bind a dataset to an asp listbox:

I have a dataset - which is a list of counties.
I need to dynamically drop the contents of the dataset (its only one column - "county")into the listbox
here a start and thanks for the help as always.

This is not working

 listBoxCounty.DataSource = dataSet
 listBoxCounty.DataMember = "County"
 listBoxCounty.DataTextField = "County"
 listBoxCounty.DataValueField = "County"
 listBoxCounty.DataBind()






0
Comment
Question by:paygo
2 Comments
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 1000 total points
ID: 16313861
Try:

 listBoxCounty.DataSource = dataSet.Tables(0)
 listBoxCounty.DataMember = "County"
 listBoxCounty.DataTextField = "County"
 listBoxCounty.DataValueField = "County"
 listBoxCounty.DataBind()
0
 
LVL 8

Accepted Solution

by:
Leo Eikelman earned 1000 total points
ID: 16314503
Try

lstReports.DataBindings.Clear()
lstReports.ValueMember = "ReportsKey"
lstReports.DataSource = dsDataSet.Tables("Reports")
lstReports.DisplayMember = "ReportDescription"

Note: the order in which these are executed is also important

Cheers,

Leo
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question