Bind arrayList to asp:dropdownlist (C#) : ArrayList « Collections « ASP.Net






Bind arrayList to asp:dropdownlist (C#)

<%@Page Language="c#" %>
<script runat="server" Language="c#">
  void Page_Load() 
  {
    ArrayList AnimalArrayList = new ArrayList();
    AnimalArrayList.Add("Dog");
    AnimalArrayList.Add("Cat");
    AnimalArrayList.Add("Elephant");
    AnimalArrayList.Add("Lion");
    AnimalArrayList.Add("Cat");
    MyDropDownList.DataSource = AnimalArrayList;
    MyDropDownList.DataBind();
}
</script>
<html>
<form id="Form1" method="post" runat="server">
  <asp:dropdownlist id="MyDropDownList" runat="server" />
</form>
</html>

           
       








Related examples in the same category

1.ArrayList: insert value by index (VB.net)
2.ArrayList: remove item (VB.net)
3.ArrayList: remove item by index (VB.net)
4.Use array and ArrayList (VB.net)
5.Inset element to ArrayList by index (C#)
6.Remove object from ArrayList (C#)
7.Remove object from ArrayList by Index (C#)
8.Use ArrayList to fill dropdown value (C#)