Plz help me by providing the code to bind a drop down list using C#.
According to the forum rules, giving code blindly is not the right way to answering anyone's question.
Why are you so lethargic to find a good tutorial on that subject as it is a basic thing to learn,not a critical one.There are plenty of resources in NET where you can have the codes and logic behind the code.
Moreover your application is a Web or Windows apllication????
In a simple way I can say....
Populate a
Dataset(say mydataset) with the records you are fetching from database with SQL query.(Otherwise you can make a table inside a dataset variable by your own and can put your records Hard-coded)
make the Datasource property of your dropdown to the Dataset.
Now set the following.......
In case of Web application
-
-
DropdownList1.Datasource=mydataset;
-
DropdownList1.DataKeyField="Primary key field name of your table";
-
DropdownList1.DataValueField="Field name of your table you want to show in dropdown";
-
In case of Windows application
-
-
DropdownList1.Datasource=mydataset
-
DropdownList1.ValueMember="Primary key field name of your table"
-
DropdownList1.DisplayMember="Field name of your table you want to
-
show in dropdown"