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

Posted on 2006-03-28
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"

Question by:paygo
    LVL 52

    Assisted Solution

    by:Carl Tawn

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

    Accepted Solution


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

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



    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    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…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now