Hi,
You can bind dropdownlist by using these ways.
1. By using ListItemCollection.
2. By using Datatable.
3. By using Dictionary.
In your Aspx
<div>
<asp:dropdownlist id="drpDownNames" runat="server" xmlns:asp="#unknown">
</asp:dropdownlist>
</div>
In Your Aspx code behind file
ListItemCollection collection = new ListItemCollection();
collection.Add(new ListItem("Suits"));
collection.Add(new ListItem("Harvey Spector"));
collection.Add(new ListItem("Jessica Pearson"));
collection.Add(new ListItem("Mike Ross"));
collection.Add(new ListItem("Donna Paulson"));
collection.Add(new ListItem("Rachel"));
collection.Add(new ListItem("Travis Tanner"));
drpDownNames.DataSource = collection;
drpDownNames.DataBind();
2. By Using Datatable
DataTable dtName = new DataTable();
dtName.Columns.Add(new DataColumn("DisplayMember"));
dtName.Columns.Add(new DataColumn("ValueMember"));
dtName.Rows.Add("Suits","0");
dtName.Rows.Add("Harvey Spector","1");
dtName.Rows.Add("Jessica Pearson","2");
dtName.Rows.Add("Mike Ross","3");
dtName.Rows.Add("Donna Paulson","4");
dtName.Rows.Add("Rachel","5");
drpDownNames.DataSource = dtName;
drpDownNames.DataTextField = dtName.Columns["DisplayMember"].ToString();
drpDownNames.DataValueField = dtName.Columns["ValueMember"].ToString();
drpDownNames.DataBind();
3. By Using Dictionary
Dictionary<string,> namesCollection = new Dictionary<string,>();
namesCollection.Add("Suits", "0");
namesCollection.Add("Harvey Spector", "1");
namesCollection.Add("Jessica Pearson", "2");
namesCollection.Add("Mike Ross", "3");
namesCollection.Add("Donna Paulson", "4");
namesCollection.Add("Rachel", "5");
drpDownNames.DataSource = namesCollection;
drpDownNames.DataTextField = "Key";
drpDownNames.DataValueField = "Value";
drpDownNames.DataBind();
As we can see if we use datatable or Dictionary, explicitly we need to mention datavaluefield and display member, but in case of ListItemCollection we do not need to set these two properties.
Ultimately, this is your choice which ever makes you more understandable and easy to implement.
Hope this helps.