473,383 Members | 1,803 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,383 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 1631
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....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.