top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

how to bind arraylist with dropdownlist in asp net application

0 votes
421 views
how to bind arraylist with dropdownlist in asp net application
posted May 21, 2016 by Sathaybama

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
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";
answer May 21, 2016 by Shivaranjini
...