Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
drpBusinessUnit.Items.Insert(0, new ListItem("", "0"));
           drpBusinessUnit.Items.Insert(-1, new ListItem("--All--", "-1"));




This is what i am trying to add after binding of fropdown .. i wanted to add two more items to the dropdown ... at 0 index its no problem , but i want one more item to be added above the 0 index , value is important for me ..
Posted

SQL
drpBusinessUnit.Items.Insert(0, new ListItem("", "0"));
           drpBusinessUnit.Items.Insert(0, new ListItem("--All--", "0"));



Make it 0(zero) in both it will work bcause after adding one item at zero index and when you add second item the first will become 1
try it.


Accept it if its work for you
 
Share this answer
 
Comments
Torakami 11-Jun-14 8:25am    
is it ?? let me try bro ..
Torakami 11-Jun-14 8:27am    
worked it .. take a five star ... you rock man ..
Awadhendra Tripathi 11-Jun-14 9:05am    
:)
Torakami 11-Jun-14 8:27am    
I was banging my head like a hell for this ..I knew there must be somone who will come for me to rescue ... and there u r
Awadhendra Tripathi 11-Jun-14 9:06am    
:)Enjoy....
drpBusinessUnit.Items.Insert(-1, new ListItem("--All--", "-1"));



check this line you have passed the invalid index
 
Share this answer
 
Comments
Torakami 11-Jun-14 8:25am    
dude i know i am putting invalid index there .. but i am trying to do somthing like that

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



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