473,385 Members | 1,396 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,385 software developers and data experts.

DropDown not populating?

Doing the simple DropDown List binding using the method NextResult()
But its just not populating ..
what am i missing
Its populating the 3 DropDwonList but no Data?
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
Dim sqlConnection As SqlConnection = New SqlConnection
sqlConnection.ConnectionString =
ConfigurationSettings.AppSettings("northwind")
sqlConnection.Open()
Dim sqlCommand As SqlCommand = New SqlCommand
sqlCommand.Connection = sqlConnection
sqlCommand.CommandText = "SELECT ProductName FROM
Products;SELECT CompanyName FROM Shippers;SELECT LastName FROM Employees"

Dim sqlReader As SqlDataReader
sqlReader = sqlCommand.ExecuteReader
DropDownList1.DataSource = sqlReader
DropDownList1.DataValueField = "ProductID"
DropDownList1.DataTextField = "ProductName"
DropDownList1.DataBind()

sqlReader.NextResult()

Dropdownlist2.DataSource = sqlReader

DropDownList1.DataValueField = "ShipperID"
DropDownList2.DataTextField = "CompanyName"
DropDownList2.DataBind()

sqlReader.NextResult()

Dropdownlist3.DataSource = sqlReader
DropDownList1.DataValueField = "EmployeeID"
DropDownList3.DataTextField = "LastName"
DropDownList3.DataBind()
sqlReader.Close()
sqlConnection.Close()
End If
End Sub
Nov 19 '05 #1
1 1882
This works as expected. The thing odd about your code is that your select
statement is only pulling back one column for each of the SQL statements
but you're trying to access two different columns for your DDLs - one for
ProductName and the other for ProductID. You should add ProductID, ShipperID
and EmployeeID to your column lists in the SQL.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Doing the simple DropDown List binding using the method NextResult()
But its just not populating ..
what am i missing
Its populating the 3 DropDwonList but no Data?
Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not IsPostBack Then
Dim sqlConnection As SqlConnection = New SqlConnection
sqlConnection.ConnectionString =
ConfigurationSettings.AppSettings("northwind")
sqlConnection.Open()
Dim sqlCommand As SqlCommand = New SqlCommand
sqlCommand.Connection = sqlConnection
sqlCommand.CommandText = "SELECT ProductName FROM
Products;SELECT CompanyName FROM Shippers;SELECT LastName FROM
Employees"
Dim sqlReader As SqlDataReader
sqlReader = sqlCommand.ExecuteReader
DropDownList1.DataSource = sqlReader
DropDownList1.DataValueField = "ProductID"
DropDownList1.DataTextField = "ProductName"
DropDownList1.DataBind()
sqlReader.NextResult()

Dropdownlist2.DataSource = sqlReader

DropDownList1.DataValueField = "ShipperID"
DropDownList2.DataTextField = "CompanyName"
DropDownList2.DataBind()
sqlReader.NextResult()

Dropdownlist3.DataSource = sqlReader
DropDownList1.DataValueField = "EmployeeID"
DropDownList3.DataTextField = "LastName"
DropDownList3.DataBind()
sqlReader.Close()
sqlConnection.Close()
End If
End Sub


Nov 19 '05 #2

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

Similar topics

2
by: Lamine Darbouche | last post by:
Can anybody help? I need to have three list boxes automatically populating each other, (ie when region is selected from the first listbox, it will populate automatically the second one which is...
13
by: melih.onvural | last post by:
Group, I'm having a tough time understanding some of the previous posts on this topic so I wanted to write what I've tried and hope that you can help me troubleshoot. I have a dropdown populated...
3
by: to_rgoyal | last post by:
Hi All, I am creating one web base application using ASP.net and C#. I am populating dropdown lists of my web pages using database. I am using this code: con = new...
2
by: tmeister | last post by:
I must be missing something obvious. I have a drop down list in asp.net and it populates the states from a database. When I view the source of the page I get the standard option tags with the...
1
by: Mike P | last post by:
I am populating a drop down column in a datagrid on page load. Here is my code : <asp:TemplateColumn> <ItemTemplate> <asp:DropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt"...
3
by: CSharpguy | last post by:
I'm trying to populate a drop down with dates from a data field in my data base but I want the format like MM/dd/yyyy instead of 1/1/2006 12:00 PM How can I my date to show as 1/1/2006? I'm...
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
3
by: femin | last post by:
Hi all, I am trying to develope one web application using vb.net. i have two dropdownlist boxes.1st ddlist i am binding on page load event. The 2nd ddlist i am populating by ajax by taking the id...
0
by: koonda | last post by:
Hi all, I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.