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 question

Status
Not open for further replies.

needhelpso

Programmer
Feb 14, 2004
11
0
0
US
Hi all,
I want to populate a drop down list with the integers 1 through 52. Instead of writing out a list item for each item I want to create an array to store the 52 values and then bind them to the dropdownlist. Any ideas on how to code this?
 
Here is what I have so far:

X=0
While x<=52
Mystring(x)=x
dropdownlist2.datatextfield=&mystring(x)&
x=x+1
end while
End Sub


Does not work though
 
needhelpso,

Why not use the Add method of the listbox control. I am not a VB programmer, but in C# you would loop through (1-52) and add them to your control (in this case your dropdownlist).

for (int i=0;i<53;i++)
Your_dropdownlist.Items.Add(new ListItem(i,i));//(text,value);

I hope that this helps. You could convert it to VB.

Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top