Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a drop down list..
i need to retrieve data from a particular column in my sql table & when i click click on the dropdown list the data present in my table(column) should load

please explain me how to do
Posted
Updated 23-Oct-13 8:20am
v2

If you are using Windows Forms, have a look at: ComboBox.DataSource Property[^]

If you are using ASP.Net, have a look at: Binding ASP.NET DropDownList to data structures[^]

The above examples shows how to bind to lists - and below you'll find an example of how to retrive a list of records from a database:

Simple Sample with Entity Framework [^]

Best regards
Espen Harlinn
 
Share this answer
 
Youu can use this code where you want OnPageLoad etc


Dataset Ds =new Dataset();
sqlDataadpter ad=new sqldataadpter("select column1,column2 from table1",con);
ad.fill(Ds);

DropDownList1.datasource=Ds.tables[0].defaultview;
DropDownList1.DataBind();
DropDownList1.DataTextField=Ds.table[0].column["column1"].tostring();
DropDownList1.DataValueField=Ds.table[0].column["column2"].tostring();
 
Share this answer
 

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