R4R
Right Place For Right Person TM
R4R ASP.Net with C# ASP.NET Tutorials Bind a ArrayList to DropDownList
previous

Home

Next

How to Bind a ArrayList to DropDownList in ASP.Net

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            System.Collections.ArrayList 
            myList = new System.Collections.ArrayList();
            myList.Add("Zero");
            myList.Add("One");
            myList.Add("Two");
            myList.Add("Three");
            myList.Add("Four");
            myList.Add("Five");
            DropDownList1.DataSource = myList;
            DropDownList1.DataBind();
        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label1.Text = "You Select a "+DropDownList1.SelectedItem.Text;
    }
}

Out Put:

previous

Home

Next


Tolal:0 Click:
Show All Comments

Post Your Comments

Your Name:

Your Email ID :
Comments :
URL
  =* Enter SUM

New Updates

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R