Binding dropdown through arraylist

Sandhyab
Posted by Sandhyab under ASP.NET category on | Points: 40 | Views : 1482
<asp:DropDownList ID="dropCountries" runat="server">
</asp:DropDownList>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDropDown();
dropCountries.DataSource = BindDropDown();
dropCountries.DataBind();
dropCountries.Items.Insert(0, new ListItem("--Select--", ""));
}

}

private object BindDropDown()
{
ArrayList arCountries = new ArrayList();
arCountries.Add("INDIA");
arCountries.Add("USA");
arCountries.Add("UK");
arCountries.Add("PAKISTHAN");
return arCountries;

}
}

Comments or Responses

Login to post response