473,800 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s)
If Not IsPostBack Then
Dim sqlConnection As SqlConnection = New SqlConnection
sqlConnection.C onnectionString =
ConfigurationSe ttings.AppSetti ngs("northwind" )
sqlConnection.O pen()
Dim sqlCommand As SqlCommand = New SqlCommand
sqlCommand.Conn ection = sqlConnection
sqlCommand.Comm andText = "SELECT ProductName FROM
Products;SELECT CompanyName FROM Shippers;SELECT LastName FROM Employees"

Dim sqlReader As SqlDataReader
sqlReader = sqlCommand.Exec uteReader
DropDownList1.D ataSource = sqlReader
DropDownList1.D ataValueField = "ProductID"
DropDownList1.D ataTextField = "ProductNam e"
DropDownList1.D ataBind()

sqlReader.NextR esult()

Dropdownlist2.D ataSource = sqlReader

DropDownList1.D ataValueField = "ShipperID"
DropDownList2.D ataTextField = "CompanyNam e"
DropDownList2.D ataBind()

sqlReader.NextR esult()

Dropdownlist3.D ataSource = sqlReader
DropDownList1.D ataValueField = "EmployeeID "
DropDownList3.D ataTextField = "LastName"
DropDownList3.D ataBind()
sqlReader.Close ()
sqlConnection.C lose()
End If
End Sub
Nov 19 '05 #1
1 1899
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.EventArg s)
If Not IsPostBack Then
Dim sqlConnection As SqlConnection = New SqlConnection
sqlConnection.C onnectionString =
ConfigurationSe ttings.AppSetti ngs("northwind" )
sqlConnection.O pen()
Dim sqlCommand As SqlCommand = New SqlCommand
sqlCommand.Conn ection = sqlConnection
sqlCommand.Comm andText = "SELECT ProductName FROM
Products;SELECT CompanyName FROM Shippers;SELECT LastName FROM
Employees"
Dim sqlReader As SqlDataReader
sqlReader = sqlCommand.Exec uteReader
DropDownList1.D ataSource = sqlReader
DropDownList1.D ataValueField = "ProductID"
DropDownList1.D ataTextField = "ProductNam e"
DropDownList1.D ataBind()
sqlReader.NextR esult()

Dropdownlist2.D ataSource = sqlReader

DropDownList1.D ataValueField = "ShipperID"
DropDownList2.D ataTextField = "CompanyNam e"
DropDownList2.D ataBind()
sqlReader.NextR esult()

Dropdownlist3.D ataSource = sqlReader
DropDownList1.D ataValueField = "EmployeeID "
DropDownList3.D ataTextField = "LastName"
DropDownList3.D ataBind()
sqlReader.Close ()
sqlConnection.C lose()
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
2593
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 the TOWNS and when the town is selected is should populate the third one AREA) all data is in the database in one table. Any idea??? Many thanks in adavance. Lamine
13
2875
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 from a table and I want to take that selection and use it to populate the next dropdown. So far: 1) I tried using a query that said select specificissue from specific_issue and used as my criterion !!
3
4065
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 SqlConnection(connectionString); SqlCommand getresult = new SqlCommand("select distinct(owner) from issue_log",con); con.Open();
2
7390
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 associated values. It all looks good. When I submit the form and some of the required fields aren't filled in the dropdown always reset to the first item in the list. First, how do I get it to stick. I've tried setting enableviewstate to true, but...
1
1775
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" Runat=server DataValueField="UserName" DataTextField="UserName" DataSource='<%# GetUserList() %>'>
3
1993
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 populating the dropdown via a dataset and doing a: string time = Convert.ToDateTime(dataset.tables.rows.toString()).ToShortDateString(); dropdown.datatexfield = time; dropdown.datavaluefield = time dropdown.databind();
5
11904
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 dropdown list control does not retain its SelectedValue. Unless I read the SelectedValue right after the control has been loaded, populated, and assigned with its original value (and of course that is
3
6798
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 from 1st. My problem is, when i am trying to save the value on button click event that field is becomming null and i am not able to save the details.Can anyone help me to get that value on the server side.please.........
0
1706
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 SQL statements in the Data Acess Layer to create more secure web service application. The Web service class is also in the Data Access Layer. I need to populates the 4 Dropdown list boxes on the web form from one table. I have Customer table which...
0
9694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10509
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10281
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10256
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9095
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7584
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6824
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4152
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2953
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.