Arraylist Asp.net .................
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
lblmessage.Text = "you have selected:<br>" + DropDownList2.SelectedItem.Value;
}
//Array list
ArrayList animalarray = new ArrayList();
animalarray.Add("dog");
animalarray.Add("peacock");
animalarray.Add("monkey");
animalarray.Add("cock");
animalarray.Add("elephant");
animalarray.Add("snake");
animalarray.Insert(1, "dogs");
animalarray.Remove("cock");
animalarray.RemoveAt(0);
DropDownList1.DataSource = animalarray;
DropDownList1.DataBind();
}
Source Design:
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:Label ID="lblmessage" runat="server"></asp:Label>
No comments:
Post a Comment