Manually insert items into DDL after data binding...

Posted by WeeShian on Stack Overflow See other posts from Stack Overflow or by WeeShian
Published on 2010-01-04T02:25:00Z Indexed on 2010/03/26 13:03 UTC
Read the original article Hit count: 344

Filed under:
|

I have a dropdownlist, which dynamically populate data from SQL Server and i wanna manually insert two items on top of the DDL after data binding. So, the DDL would has data something like this:

Select Branch (manually insert)
ALL (manually insert)
AIR
AMP
ABG
...

I tried to achieve it by using code below:

ddlBranch.Items.Insert(0, "Select Branch")
ddlBranch.Items(0).Value = CMM.sExcVal1

ddlBranch.Items.Insert(1, "ALL")
ddlBranch.Items(1).Value = "ALL" 

but it comes out giving me the data like this:

Select Branch (manually insert)
ALL (manually insert)
('AIR' branch should be here but it's gone)
AMP
ABG
...

After manually insert the 'ALL' item into the DDL, the 'AIR' is gone which is already replaced by the 'ALL'. How can i remain all the data from server and at the same time i can manually insert two items?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about dropdownlist