Binding the dropdown values through code

This is something very basic and simple, most of the beginners like me encounters. You might wonder how to bind the list elements manually into the dropdown list instead binding the data source in If you have ended up in the same, its is the right place to figure it out. Here I go,

protected void Page_Load(object sender, EventArgs e) //values are populated when the page is requested by the client
string[] names = {“Sharmili”,”Deepika”,”Rathinam”,”Anitha”}; //Get the dropdown list elements to be populated

foreach (string i in names) //when you use foreach, you need not bother about array index

//The other way to bind the values one by one is shown below


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s