I know to add an item as the first item, I use:
ddlTest.Items.Insert(0, new ListItem("---New First Item---", "-1"));
I tried -1
as the index but then I didn't even see the item. How to I add an item as the last item in the list without knowing its index number (because the dropdown is populated from a database)?
to add to the LAST position, just add to the list as
ddlTest.Items.Add(new ListItem("---New First Item---", "-1"));
as it will append to the last place by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With