protected void Page_Load(object sender, EventArgs e)
{
ArrayList list = new ArrayList();
list.Add(new Item("I001", "Item1"));
list.Add(new Item("I002", "Item2"));
list.Add(new Item("I003", "Item3"));
list.Add(new Item("I004", "Item4"));
DropDownList1.DataSource = list;
DropDownList1.DataTextField = "Code";
DropDownList1.DataValueField = "Name";
DropDownList1.DataBind();
}
The below code demonstrates how to bind an ArrayList with combobox control in a windows application.
comboBox1.DataSource = list;
comboBox1.ValueMember = "Code";
comboBox1.DisplayMember = "Name";