Adding item to Databoud Drop Down control

It was quite a struggle for me to add a string “All” to a data bound drop down list box. It was really becoming for me a challenge as everytime my client would bring this point and when I tell my problem he would give some stupid way to solve this issue. So atlast taken this challenge.

Suppose you have drop down list box, and you have SqlDataSource to bound it some data. In my case I was trying to populate with some user list. Now there was an option for All which I have to add initially I added a checkbox next to the dropdown but then I got a way to do it googling. The solution is to use the Insert method to add an list item to the drop down

ListItem item = new ListItem(“All”, “All”);

cmbUseList.Items.Insert(0,item);//The first is the index

Thanks to the customer who challenged to bring the good solutions.


One Response

  1. Debasish, a little mistake with spelling in the heading – “Databoud” 🙂

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

%d bloggers like this: