Click here to Skip to main content
15,304,276 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a weird issue on one drop down list.
It has databound items and is dependant on another dropdownlist.
So if I select a value from the 1st dropdown list then this dropdownlist in question will have databound items.

the issue that I am having is that I want to add a value at index 0 that says "ALL" and there after display the databound items but this is not working. I have it working for the rest of the dropdowns beside this 1.

here is my code:

ddlPromoSuffEdit.Items.Add(new ListItem("All", "")); //this is not being added in but data items are populated
ddlPromoSuffEdit.DataSourceID = "";
ddlPromoSuffEdit.DataSource = odsPromoSuffEdit.Select();

1 solution


If you DataBind() your list before inserting the new ListItem you should find it will display as requested.

Something like this should work:
ddlPromoSuffEdit.DataSourceID = "";
ddlPromoSuffEdit.DataSource = odsPromoSuffEdit.Select();
//Insert new ListItem ... 
ddlPromoSuffEdit.Items.Insert(0, (new ListItem("All", "")));

... hope it helps.
Perfect. Take a 5. :)
hypermellow 15-Apr-15 7:35am
... thank you! :-)
Welcome. :)
Then you have other issue. Please debug and watch the items after this code.
Kats2512 15-Apr-15 8:01am
ok debugged and found the issue. this worked well. 5 star!!!!
hypermellow 15-Apr-15 8:38am
Glad you got it sorted. :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900