| Author: Hari 03 Nov 2009 | Member Level: Gold | Rating:  Points: 2 |
Hi,
Please find below the link. It has step by step tutorial
http://programming.top54u.com/post/ASP-Net-DropDownList-SQL-Datasource-Databinding.aspx
Also attached is a sample in VS 2008 SP1 which connectes to northwind database.
DropDownListDB.rar |
| Author: Anuraj 03 Nov 2009 | Member Level: Diamond | Rating:  Points: 2 |
Try this
Dropdown1.DataTextField = "Id"; Dropdown1.DataValueField = "Value2Display"; Dropdown1.DataSource = DataTable; Dropdown1.DataBind();
Thanks Anuraj THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS. BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT. dotnetthoghts
|
| Author: greeny_1984 03 Nov 2009 | Member Level: Diamond | Rating:  Points: 2 |
Hi,
You can fetch data from database using a query and assign the dataset to dropdownlist.check this ex
sqlconnection conn=new sqlconnection("//connection string"); conn.open(); sqlcommand cmd=new sqlcommand("select * from table",conn); sqldataadapeter da=new sqldatadapter(cmd); dataset ds=new dataset(); da.fill(ds); dropdownlist1.datasource=ds.tables[0]; dropdownlist1.DataTextfield="columnname"; dropdownlist1.DataValuefield="columnname"; dropdownlist1.Databind();
Regards, Greeny_1984
Rate this Response[Excellent/Good/Poor] FRESHERS check this link Need help from me join here
|
| Author: Deepika Haridas 03 Nov 2009 | Member Level: Diamond | Rating:   Points: 3 |
Hello,
Check this link
http://www.dbtutorials.com/advanced/populatingdropdown-csharp.aspx
Thanks & Regards, Deepika Editor
If U want to shine like a SUN..First U have to burn like the SUN!! Need a Guide? Join my mentor program..
|