473,809 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to populate dropdown list from database?

I saw an example of this which talked about assigning valueTextField and
DataTextField. So I have twenty items coming back from the database(I use a
dataadapter), do I need to go thru a loop to assign each item in the Dropdown?
Is there a way to just assign the datasource to a dataset (that's filled
with data)?

Thanks a lot

Merdaad
Nov 18 '05 #1
3 4073


--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 2.
MIEMBRO ACTIVO DE ALIANZADEV
"Merdaad" <Me*****@discus sions.microsoft .com> escribió en el mensaje
news:5A******** *************** ***********@mic rosoft.com...
I saw an example of this which talked about assigning valueTextField and
DataTextField. So I have twenty items coming back from the database(I use a dataadapter), do I need to go thru a loop to assign each item in the Dropdown? Is there a way to just assign the datasource to a dataset (that's filled
with data)?

Thanks a lot

Merdaad

Nov 18 '05 #2
private void cargarProveedor es()

{

SqlDataAdapter myadapter = new SqlDataAdapter( "select idproveedor,
nombreproveedor from proveedores order by nombreproveedor asc",
sqlConnection1) ;

DataSet myds = new DataSet();

myadapter.Fill( myds);

comboproveedore s.DataSource= myds;

comboproveedore s.DataTextField ="nombreproveed or";

comboproveedore s.DataValueFiel d = "idproveedo r";

comboproveedore s.DataBind();

}
--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 2.
MIEMBRO ACTIVO DE ALIANZADEV
"Merdaad" <Me*****@discus sions.microsoft .com> escribió en el mensaje
news:5A******** *************** ***********@mic rosoft.com...
I saw an example of this which talked about assigning valueTextField and
DataTextField. So I have twenty items coming back from the database(I use a dataadapter), do I need to go thru a loop to assign each item in the Dropdown? Is there a way to just assign the datasource to a dataset (that's filled
with data)?

Thanks a lot

Merdaad

Nov 18 '05 #3
Thanks that worked great.

"Luis Esteban Valencia" wrote:
private void cargarProveedor es()

{

SqlDataAdapter myadapter = new SqlDataAdapter( "select idproveedor,
nombreproveedor from proveedores order by nombreproveedor asc",
sqlConnection1) ;

DataSet myds = new DataSet();

myadapter.Fill( myds);

comboproveedore s.DataSource= myds;

comboproveedore s.DataTextField ="nombreproveed or";

comboproveedore s.DataValueFiel d = "idproveedo r";

comboproveedore s.DataBind();

}
--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 2.
MIEMBRO ACTIVO DE ALIANZADEV
"Merdaad" <Me*****@discus sions.microsoft .com> escribió en el mensaje
news:5A******** *************** ***********@mic rosoft.com...
I saw an example of this which talked about assigning valueTextField and
DataTextField. So I have twenty items coming back from the database(I use

a
dataadapter), do I need to go thru a loop to assign each item in the

Dropdown?
Is there a way to just assign the datasource to a dataset (that's filled
with data)?

Thanks a lot

Merdaad


Nov 18 '05 #4

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

Similar topics

20
12440
by: Dannyboyo | last post by:
I have what I hope is a simple request. I can't really code in javascript, but I am pretty good at cusomizing it with slight modifications. I code in ASP and HTML. I am trying to capture customer input of product names to put on custom labels we make. Some of the labels will have our product names on them, but the customer can add other products that we do not sell. So, on my product detail page I want a textbox that can have rows copied...
0
2442
by: Nithin | last post by:
My code as an txt attachment. I have 2 drop down list boxes that on selection populate text boxes from my database table. I am able to display the correct values in these text boxes. I have 2 questions: 1) I would like the user update these text fields that get populated with data from the database. For some reason I get the error when I change the textbox value.
1
1200
by: Johhn | last post by:
I am using VS 2005 and MS ACCESS database, i need to populate dropdown list box eith Items from row 1 to n and from x to y Any code samples? I am usig VB language. Thanks. Who gives me a solution will get a present from mee.
3
1993
by: Jerry | last post by:
Hello everyone! I'm trying to populate a dropdown list from SQL Server but it's not being populated. I've tried all sorts of suggestions and examples that I found from Google but I just can not get it to work. I am able to access the database from other pages and display a list of records, but I just can't get the data to go into the dd list. Below is my code:
5
5919
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique CompanyID's. The second combobox will contain unique memberID's. Each of the tables that I have to search contain a CompanyID and a memberID field, and these fields are not unique in the respective tables. Like CompanyID, MemberID
3
6900
by: Yi Chen | last post by:
We have a drop down list on a PHP page, with several product names, and when people click one item, we will refresh the same page with the product name as parameter, and in turn we want to include a HTML file into the content area of the same page. I know it is recommended to put everything into database, but we want the web site to be very "portable", so the drop-downlist and the content should both in text files. Let's say the...
0
1616
by: Kay O'Keeffe | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp textbox control which has a 'TextMode' property and when clicked on, displays as a dropdown list with 3 values, I want to have a similar type property with a dropdown style.
11
7402
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and the Dropdown doesnt have any items.. The requirement is that as soon as one goes on typing the letters in the StudentName-textbox the corresponding matching names have to appear
5
17688
by: joshua.nicholes | last post by:
I have an access database that consists of two tables.A data collection table and a species list table. The data collection table has about 1500 records in it and the species list has about 600. The species list has 7 fields the first is a four digit unique identifier (species) it is set as the primary key. I have created a relationship to the data collection table which also has a species field (4 digit id). In my form I have the species...
1
1872
by: fran7 | last post by:
Hi, Anyone know how to populate a dropdown list with data from database. I have an interface that generates the following code for names in my database. ..asp <%If Trim(rsCard("Author"))<>"" Then%> <%=rsCard("Author")%><%End If%> .. How does one populate a dropdown list??
0
9602
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10383
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
10120
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
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
7661
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
6881
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();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.