Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can u tell me how to show data from database to comboBox??:)
Posted
Updated 29-Jun-10 0:04am
v2
Comments
khaula 2 29-Jun-10 3:18am    
thanx:)

Go here:
MSDN: ComboBox Class[^]

Read all about them!
 
Share this answer
 
Get Data from database then assign to Combobox as below.

C#
Dropdownlist1.DataSource = dtTemp; //Sample Datatable which contains data
Dropdownlist1.DataBind();
Dropdownlist1.DataTextField = "EmployeeName";
Dropdownlist1.DataValueField = "EmployeeID";


Mate, you must need C# Book for your basic knowledge in that. Happy coding.
 
Share this answer
 
'select idfield as ID, namefield as Name from table
fill t result of query to a dataset after that

combobox. datasource =dataset.tables(0)
cmbDrCr.DisplayMember="ID"
cmbDrCr.ValueMember="Name"
 
Share this answer
 
v2
First assign data from database to a dataset or a datatable
Then bind ComboBox using the data

MIDL
comboBox1.DataSource = dataSet1.Tables["TableName"];
comboBox1.DisplayMember = "Column Name";
 
Share this answer
 
Dear friend,
First of all if u are beginner in C#.Please download Murach C# 2008 by wrox publication.That may be best for beginner to learn C#.

let go to the point
if your combo box name cmbEmployee
then
declaire DataTable
DataTable dt=new DataTable();
Here for dt=Query required from database
cmbEmployee.datasource=dt;
if it is Desktop Application then
cmbEmployee.DisplayMember="Column Name";
if it is asp then
cmbEmployee= "EmployeeName";
cmbEmployee.DataValueField = "EmployeeID";
cmbEmployee.DataBind();

Masud
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900