Drop Down List Displays

Posted on 2009-04-03
Last Modified: 2013-11-26
I'm trying to populate a drop down list with one column of a sql view but instead I'm getting on every row. I've read about the column names etc. being incorrect etc and have checked that. I've also tried using dbo.vDepts and vDepts for the view name but it made no difference.

Thanks in advance!!
Imports System
Imports System.Collections
Imports System.Data
Imports System.Net.Mail
Imports System.Net
Imports System.IO
Imports System.Security.Permissions
Imports System.Text
Imports System.DirectoryServices
Partial Public Class _Default
    Inherits System.Web.UI.Page
    Dim strUser As String
    Dim strDate As Date
    Dim DS As System.Data.DataSet
 Private Sub FillDropdown()
        Dim sConn As Data.SqlClient.SqlConnection
        Dim sComm As Data.SqlClient.SqlCommand
        Dim sAdapt As Data.SqlClient.SqlDataAdapter
        sConn = New Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("MyConnection2").ConnectionString)
        sComm = New Data.SqlClient.SqlCommand("Select Depts from dbo.vDepts", sConn)
        sAdapt = New Data.SqlClient.SqlDataAdapter(sComm)
        DS = New DataSet
        DropDownList10.DataSource = DS
    End Sub

Open in new window

Question by:JB4375
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 15

Accepted Solution

oobayly earned 500 total points
ID: 24061480
You should set the DataTextField property for the drop down list to the column you wish to display:
DropDownList10.DataTextField = "Depts "

Open in new window


Author Comment

ID: 24061849
It works!!
Thanks Oobayly!!

Author Closing Comment

ID: 31566313
Right on the money the first time!! Thanks!!

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

690 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