473,396 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Drop Down List not filling from dataset

Dim dtUsers As New DataTable

Running the following code fills ListBox1 but not ddlUsers (a drop down
list).

Any ideas?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Call FillUsers()

With ListBox1

..DisplayMember = "UserName"

..ValueMember = "UserID"

..DataSource = dtUsers

End With

With ddlUsers

..DisplayMember = "UserName"

..ValueMember = "UserID"

..DataSource = dtUsers

End With

End Sub

Private Sub FillUsers()

Dim oSQLHandler As New CRI.SQLHandler("CRISQL2", "Admin", "sa", "")

Dim oSQLCmd As New SqlCommand

Dim oDataAdaptor As New SqlDataAdapter

With oSQLCmd

..CommandText = "pGetJobUsers"

..CommandType = CommandType.StoredProcedure

..Connection = oSQLHandler.OpenConnection

End With

With oDataAdaptor

..SelectCommand = oSQLCmd

..Fill(dtUsers)

End With

oSQLHandler.CloseConnection()

End Sub
Jul 21 '05 #1
1 1633
You have to call DataBind().

"JeffOfJersey" <jm*******@comreginc.com> wrote in message
news:#w**************@TK2MSFTNGP14.phx.gbl...
Dim dtUsers As New DataTable

Running the following code fills ListBox1 but not ddlUsers (a drop down
list).

Any ideas?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Call FillUsers()

With ListBox1

.DisplayMember = "UserName"

.ValueMember = "UserID"

.DataSource = dtUsers

End With

With ddlUsers

.DisplayMember = "UserName"

.ValueMember = "UserID"

.DataSource = dtUsers

End With

End Sub

Private Sub FillUsers()

Dim oSQLHandler As New CRI.SQLHandler("CRISQL2", "Admin", "sa", "")

Dim oSQLCmd As New SqlCommand

Dim oDataAdaptor As New SqlDataAdapter

With oSQLCmd

.CommandText = "pGetJobUsers"

.CommandType = CommandType.StoredProcedure

.Connection = oSQLHandler.OpenConnection

End With

With oDataAdaptor

.SelectCommand = oSQLCmd

.Fill(dtUsers)

End With

oSQLHandler.CloseConnection()

End Sub

Jul 21 '05 #2

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

Similar topics

2
by: ramesh | last post by:
hi, I am using Com+ in my application. It will have InsertRecords,selectRecords,updateRecords function. In the Web Form i have Drop-down list. I want to select records from SQL and add it to this...
2
by: Eric Sabine | last post by:
I am filling a drop down list from a dataset. The resultset contains data like this Joe Smith Accounting Mike Collins Engineering Joe Walter Engineering etc. The...
3
by: Russ | last post by:
I have a drop down list on a web page that I pre-fill onload from a SQL table using a SqlDataReader. The line of code that fills the drop down looks like this while(myReader.Read()) {...
3
by: Stephen Adam | last post by:
Hi there, I'm sure i'm missing something really simple here, all i want to do is get the value of the selected item in a list box. Even after much fiddling about last night I still could not get...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
7
by: Miguel Dias Moura | last post by:
Hello, i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists. Each group of Drop Down Lists include 3 Drop Down Lists for date such as: DAY, MONTH, and YEAR. I don't want...
1
by: JeffOfJersey | last post by:
Dim dtUsers As New DataTable Running the following code fills ListBox1 but not ddlUsers (a drop down list). Any ideas?
2
by: tom c | last post by:
I have a dropdown list box on an ASP.Net 1.1 webform. I populate it from a dataset in code. Everything looks fine and I can see all the values in the dropdownlist. I can select a value and I see...
0
by: jaeden99 | last post by:
I have a two drop down list box. The first contains district name(district id is the value) and the the second will contain the user name based on the district selected in the first drop down list....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.