Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dropdownlist.items.insert problem

Status
Not open for further replies.

ebarratt

Programmer
Apr 10, 2002
53
0
0
US
I want to populate a drop down list programmically and i'm using the syntax:

lstYSItemNumber.Items.Insert(intYSItemNumber, intYSItemNumber)

Is my understanding correct that the first parameter of the Insert operation the index in the dropdownlist collect and the second paramenter of the insert operation the text value of the dropdownlist? If so where does the value property fit in to the dropdown list? I just really want to insert a dropdownlist item with an index position of 0, value of 1, and text of 1. Could anyone supply me with the correct syntax? It would be greatly appreciated.

Thanks all! *** Any suggestions to my asp.net site would be great if your bored!
 
There are 2 Insert methods you can use.
This one:

.Insert(int index, System.Web.UI.WebocontrolsListItem item)

or the overload method:

.Insert(int index, string item);

therefore, just be more precise you could create the ListItem object first with the Value and the Text that you want, and then Insert them in the index position you desire.

hth Daren J. Lahey
Just another computer guy...
FAQ183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
Support your forums TODAY!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top