Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Drop Down List Displays system.data.datarowview

Posted on 2009-04-03
3
Medium Priority
?
674 Views
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 system.data.datarowview 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)
        sConn.Open()
 
        DS = New DataSet
        sAdapt.Fill(DS)
        sComm.ExecuteReader()
        DropDownList10.DataSource = DS
        DropDownList10.DataBind()
        sConn.Close()
 
    End Sub

Open in new window

0
Comment
Question by:JB4375
[X]
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
3 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 2000 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

0
 
LVL 1

Author Comment

by:JB4375
ID: 24061849
It works!!
Thanks Oobayly!!
0
 
LVL 1

Author Closing Comment

by:JB4375
ID: 31566313
Right on the money the first time!! Thanks!!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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 (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

636 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