How to know what is last index number in a drop down list if it is populated by using database??

Recommended Answers

All 3 Replies

>How to know what is last index number in a drop down list if it is populated by using database??

No need to worry about the size (capacity) because DropDownList uses List collection. You can use Count property of items collection to get the last index = (Count -1)

ok thankx but can you tell how to get the last item also

Try this code.

ListItem item = dropdownlist1.Items[dropdownlist1.Items.Count-1];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.